Skip to content

Commit

Permalink
Add configuration wakeupAutoplayDazetime
Browse files Browse the repository at this point in the history
  • Loading branch information
shinate committed Dec 15, 2016
1 parent 192e3a3 commit 0d8f726
Show file tree
Hide file tree
Showing 22 changed files with 2,422 additions and 2,303 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ To learn more advanced features, please refer to [WIKI](https://github.com/BE-FE
- Precondition: isAutoplay === ```TRUE```


##### wakeupAutoplayDazetime

- `{Number}`
- User click/tap behavior(eg: active a link), or if the page loses focus will stop autoplay.
- This configuration will attempt to restart autoplay after N milliseconds.
- **AutoPlay will be forced to wake up, even when the user fill in a form items !**
- **It will be blocked by "lock()"**
- Unit: ms
- Precondition: isAutoplay === ```TRUE```


##### isLooping

- `{Boolean}`
Expand Down
11 changes: 11 additions & 0 deletions README_Chinese.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ var data = [{
- 前置条件:isAutoplay === ```TRUE```


##### wakeupAutoplayDazetime

- `{Number}`
- 当用户产生点击/触摸行为(比如触发一个超链接),或者页面失去焦点时会停止自动播放
- 此项配置会在吻合上面条件之后,尝试在N毫秒后重新唤醒自动播放
- **自动播放的唤醒是强制性的,无论你在做什么,比如正在某一帧上填写表单!**
- **此项配置会被"lock()"阻止,当你设置了此项又想在某一帧停留的时候请使用"lock()"方法**
- 单位:毫秒
- 前置条件:isAutoplay === ```TRUE```


##### isLooping

- `{Boolean}`
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
"index.html",
"gulp"
],
"version": "2.2.0"
"version": "2.2.1"
}
2 changes: 1 addition & 1 deletion build/iSlider.animate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 29 additions & 6 deletions build/iSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
try {
return obj instanceof HTMLElement;
}
catch(e){
return (typeof obj==="object") &&
(obj.nodeType===1) && (typeof obj.style === "object") &&
(typeof obj.ownerDocument ==="object");
catch (e) {
return (typeof obj === "object") &&
(obj.nodeType === 1) && (typeof obj.style === "object") &&
(typeof obj.ownerDocument === "object");
}
}

Expand Down Expand Up @@ -152,7 +152,7 @@
if (!opts.dom) {
throw new Error('Container can not be empty!');
}
else if (!isDom(opts.dom)){
else if (!isDom(opts.dom)) {
throw new Error('Container must be a HTMLElement instance!');
}

Expand Down Expand Up @@ -186,7 +186,7 @@
* version
* @type {string}
*/
iSlider.VERSION = '2.2.0';
iSlider.VERSION = '2.2.1';

/**
* Event white list
Expand Down Expand Up @@ -660,6 +660,16 @@
*/
self.isAutoplay = opts.isAutoplay && self.data.length > 1 ? true : false;

/**
* When autoplay is enabled.
* User click/tap behavior(eg: active a link), or if the page loses focus will stop autoplay.
* This configuration will attempt to restart autoplay after N milliseconds.
* ! AutoPlay will be forced to wake up, even when the user fill in a form item
* ! It will be blocked by "lock()"
* @type {number}
*/
self.wakeupAutoplayDazetime = opts.wakeupAutoplayDazetime > -1 ? parseInt(opts.wakeupAutoplayDazetime) : -1;

/**
* Animate type
* @type {String}
Expand Down Expand Up @@ -1165,6 +1175,7 @@
break;
case 'blur':
this.pause();
this._tryToWakeupAutoplay();
break;
}
};
Expand Down Expand Up @@ -1322,6 +1333,8 @@
}

this.offset.X = this.offset.Y = 0;

this._tryToWakeupAutoplay();
};

/**
Expand Down Expand Up @@ -1817,6 +1830,16 @@
this.delay > 0 ? global.setTimeout(this.play.bind(this), this.delay) : this.play();
};

/**
* try to restart autoplay
* @private
*/
iSliderPrototype._tryToWakeupAutoplay = function () {
if (~this.wakeupAutoplayDazetime) {
this.wakeupAutoplayDazetime > 0 ? global.setTimeout(this.play.bind(this), this.wakeupAutoplayDazetime) : this.play();
}
};

/**
* Start autoplay
* @public
Expand Down
2 changes: 1 addition & 1 deletion build/iSlider.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/iSlider.plugin.BIZone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/iSlider.plugin.button.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/iSlider.plugin.dot.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d8f726

Please sign in to comment.