Skip to content

Commit

Permalink
in/outcallback添加timer,防止阻碍转场动效
Browse files Browse the repository at this point in the history
  • Loading branch information
ksky521 committed Jul 20, 2014
1 parent c44a70d commit 4837171
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
35 changes: 30 additions & 5 deletions assets/js/nodeppt.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@
}
//slide切入回调incallback
//<slide data-incallback=""
var slideInTimer;

function slideInCallBack() {
if (slideInTimer) {
clearTimeout(slideInTimer);
}
slideInTimer = setTimeout(slideInCallBack_, 1500);

}

function slideInCallBack_() {
var $cur = $slides[curIndex];
if (!$cur || ($cur && $cur.nodeType !== 1)) {
return;
Expand All @@ -102,15 +111,26 @@
}
//slide切出回调outcallback
//<slide data-outcallback=""
var slideOutTimer;

function slideOutCallBack(prev) {
if (!prev || (prev && prev.nodeType !== 1)) {
return;
}
if (slideOutTimer) {
clearTimeout(slideOutTimer);
}
slideOutTimer = setTimeout(function(){
slideOutCallBack_(prev);
}, 1500);
}

function slideOutCallBack_(prev) {
var cb = prev.dataset.outcallback;
//如果有data-outcallback那么就执行callback
cb && typeof $win[cb] === 'function' && proxyFn(cb);
}

//预加载资源
//<preload data-type="js||css" data-url="">

Expand Down Expand Up @@ -222,8 +242,13 @@

function updateSlideClass() {
var curSlide = curIndex;

var pageClass = 'pagedown';
if(pastIndex===curIndex){
$cur = $slides[curIndex];
if($cur.classList.contains('pageup')){
return;
}
}
if (pastIndex > curIndex) {
//往前翻页
pageClass = 'pageup';
Expand Down Expand Up @@ -342,11 +367,11 @@
case 72:
// H: Toggle code highlighting
$doc.body.classList.toggle('highlight-code');
setTimeout(function(){
setTimeout(function() {
$doc.body.classList.toggle('highlight-code');
},2000);
}, 2000);
break;
// 下掉宽屏模式,默认width:100%
// 下掉宽屏模式,默认width:100%
case 87:
// W: Toggle widescreen
// Only respect 'w' on body. Don't want to capture keys from an <input>.
Expand Down Expand Up @@ -647,7 +672,7 @@
prev: prevSlide,
doSlide: doSlide,
proxyFn: proxyFn
}
};

$win.Slide = Slide;

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "nodeppt",
"jsname": "nodeppt",
"description": "A simple, in-browser, markdown-driven presentation tool",
"version": "0.8.2",
"description": "A simple, in-browser, markdown-driven presentation framework",
"version": "0.8.3",
"site": "https://github.com/ksky521/nodePPT",
"author": {
"name": "Theo Wang",
Expand Down Expand Up @@ -32,8 +32,11 @@
},
"keywords": [
"ppt",
"slide",
"reveal",
"impressjs",
"presentation",
"PowerPoint",
"powerpoint",
"slideshow",
"markdown"
],
Expand Down
4 changes: 4 additions & 0 deletions ppts/css/demo.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.file-setting{
color: yellow;
}
#incallback,#outcallback{
margin-top:10px;
background-color: rgba(0,0,0,.5);
}
17 changes: 11 additions & 6 deletions ppts/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,19 @@ markdown语法如下:
[slide data-outcallback="outcallback" data-incallback="incallback" ]
## 使用回调
----
使用方法:

&#91;slide data-outcallback="outcallback" data-incallback="incallback"&#93;
* &#91;slide data-outcallback="fnName"&#93;
* 进入执行回调incallback函数
* &#91;slide data-incallback="fnName"&#93;
* 退出执行outcallback函数

亦可以组合写:

> &#91;slide data-outcallback="foo" data-incallback="bar"&#93;
即:

* 进入执行回调incallback函数
* 退出执行outcallback函数
<p id="incallback"></p>
<p id="outcallback"></p>

[slide]
## 设置slide?
Expand All @@ -373,6 +378,6 @@ https://github.com/ksky521/nodePPT

什么?这些功能还不够用?

极客模式:查看源码的nodeppt.js,相信你会找到牛逼的手机互动(摇一摇换页)功能
socket远程控制可以在手机上摇一摇换页哦~

查看项目目录ppts获取更多帮助信息
4 changes: 2 additions & 2 deletions ppts/js/demo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function outcallback(){
alert('outcallback fire');
document.getElementById('outcallback').innerHTML = 'outcallback fire';
}

function incallback(){
alert('incallback fire');
document.getElementById('incallback').innerHTML = 'incallback fire';
}

0 comments on commit 4837171

Please sign in to comment.