mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 10:31:20 -08:00
add art.isRotate
This commit is contained in:
1 parent
1cbef4c6f4
commit
af6e936854
4 files changed
+5
-4
No files matched your search
@@ -129,8 +129,7 @@ export default function progress(options) {
|
|||||||
|
|
||||||
proxy($control, 'click', (event) => {
|
proxy($control, 'click', (event) => {
|
||||||
if (event.target !== $indicator) {
|
if (event.target !== $indicator) {
|
||||||
const autoOrientation = art.plugins.autoOrientation && art.plugins.autoOrientation.state;
|
if (art.isRotate) {
|
||||||
if (autoOrientation) {
|
|
||||||
const { clientHeight } = document.documentElement;
|
const { clientHeight } = document.documentElement;
|
||||||
const percentage = event.pageY / clientHeight;
|
const percentage = event.pageY / clientHeight;
|
||||||
const second = percentage * art.duration;
|
const second = percentage * art.duration;
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ export default function gestureInit(art, events) {
|
|||||||
|
|
||||||
const onTouchMove = (event) => {
|
const onTouchMove = (event) => {
|
||||||
if (event.touches.length === 1 && isDroging && art.duration) {
|
if (event.touches.length === 1 && isDroging && art.duration) {
|
||||||
const autoOrientation = art.plugins.autoOrientation && art.plugins.autoOrientation.state;
|
|
||||||
const { clientX, clientY } = event.touches[0];
|
const { clientX, clientY } = event.touches[0];
|
||||||
const ratioX = clamp((clientX - startX) / art.width, -1, 1);
|
const ratioX = clamp((clientX - startX) / art.width, -1, 1);
|
||||||
const ratioY = clamp((clientY - startY) / art.height, -1, 1);
|
const ratioY = clamp((clientY - startY) / art.height, -1, 1);
|
||||||
const ratio = autoOrientation ? ratioY : ratioX;
|
const ratio = art.isRotate ? ratioY : ratioX;
|
||||||
const currentTime = clamp(
|
const currentTime = clamp(
|
||||||
startTime + art.duration * ratio * art.constructor.TOUCH_MOVE_RATIO,
|
startTime + art.duration * ratio * art.constructor.TOUCH_MOVE_RATIO,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export default class Artplayer extends Emitter {
|
|||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
this.isFocus = false;
|
this.isFocus = false;
|
||||||
this.isInput = false;
|
this.isInput = false;
|
||||||
|
this.isRotate = false;
|
||||||
this.isDestroy = false;
|
this.isDestroy = false;
|
||||||
|
|
||||||
this.whitelist = new Whitelist(this);
|
this.whitelist = new Whitelist(this);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default function autoOrientation(art) {
|
|||||||
setStyle($player, 'transform-origin', '0 0');
|
setStyle($player, 'transform-origin', '0 0');
|
||||||
setStyle($player, 'transform', `rotate(90deg) translate(0, -${viewWidth}px)`);
|
setStyle($player, 'transform', `rotate(90deg) translate(0, -${viewWidth}px)`);
|
||||||
addClass($player, 'art-auto-orientation');
|
addClass($player, 'art-auto-orientation');
|
||||||
|
art.isRotate = true;
|
||||||
art.emit('resize');
|
art.emit('resize');
|
||||||
}, constructor.MOBILE_AUTO_ORIENTATION_TIME);
|
}, constructor.MOBILE_AUTO_ORIENTATION_TIME);
|
||||||
}
|
}
|
||||||
@@ -32,6 +33,7 @@ export default function autoOrientation(art) {
|
|||||||
setStyle($player, 'transform', null);
|
setStyle($player, 'transform', null);
|
||||||
setStyle($player, 'transform-origin', null);
|
setStyle($player, 'transform-origin', null);
|
||||||
removeClass($player, 'art-auto-orientation');
|
removeClass($player, 'art-auto-orientation');
|
||||||
|
art.isRotate = false;
|
||||||
art.aspectRatioReset = true;
|
art.aspectRatioReset = true;
|
||||||
art.autoSize = option.autoSize;
|
art.autoSize = option.autoSize;
|
||||||
art.notice.show = '';
|
art.notice.show = '';
|
||||||
|
|||||||
Reference in new issue
Block a user