Skip to content

Commit

Permalink
修改动效
Browse files Browse the repository at this point in the history
  • Loading branch information
ksky521 committed Dec 13, 2015
1 parent dc0dc19 commit 6fc22a4
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 106 deletions.
2 changes: 1 addition & 1 deletion assets/css/nodeppt.css

Large diffs are not rendered by default.

94 changes: 49 additions & 45 deletions assets/js/nodeppt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function($win, $doc, $B, loadJS, loadCSS, undefined) {
(function ($win, $doc, $B, loadJS, loadCSS, undefined) {
//用于单页ppt预加载资源
var preloadFn = {
loadJS: loadJS,
Expand All @@ -23,7 +23,7 @@
}();

var $body = $doc.body;
var emptyFn = function() {};
var emptyFn = function () {};
var emptyArr = [];

var touchDX = 0; //touch事件x数据
Expand Down Expand Up @@ -56,7 +56,7 @@
pairs = search.split('&'),
result = {};

pairs.forEach(function(pair) {
pairs.forEach(function (pair) {
pair = pair.split('=');
if (pair[0].length > 0) {
result[pair[0]] = pair[1] || '';
Expand All @@ -67,11 +67,11 @@
}
var fullScreenApi = {
supportsFullScreen: false,
isFullScreen: function() {
isFullScreen: function () {
return false;
},
requestFullScreen: function() {},
cancelFullScreen: function() {},
requestFullScreen: function () {},
cancelFullScreen: function () {},
fullScreenEventName: '',
prefix: ''
},
Expand All @@ -94,7 +94,7 @@
if (fullScreenApi.supportsFullScreen) {
fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';

fullScreenApi.isFullScreen = function() {
fullScreenApi.isFullScreen = function () {
switch (this.prefix) {
case '':
return document.fullScreen;
Expand All @@ -104,10 +104,10 @@
return document[this.prefix + 'FullScreen'];
}
};
fullScreenApi.requestFullScreen = function(el) {
fullScreenApi.requestFullScreen = function (el) {
return (this.prefix === '') ? el.requestFullScreen() : el[this.prefix + 'RequestFullScreen']();
};
fullScreenApi.cancelFullScreen = function(el) {
fullScreenApi.cancelFullScreen = function (el) {
return (this.prefix === '') ? document.cancelFullScreen() : document[this.prefix + 'CancelFullScreen']();
};
}
Expand All @@ -123,7 +123,7 @@
var event = document.createEvent('Event');
event.initEvent('ppt' + name, true, true);
event.stopped = false;
event.stop = function() {
event.stop = function () {
event.preventDefault();
event.stopPropagation();
event.stopped = true;
Expand Down Expand Up @@ -241,7 +241,7 @@


//事件:keypress接管,build接管
['Keypress', 'Build'].forEach(function(v) {
['Keypress', 'Build'].forEach(function (v) {
var callback = dataset['on' + v];
callback = getCallbackFuncFromName(callback);
if (callback && typeof callback === 'function') {
Expand All @@ -252,9 +252,13 @@
//检测iframe
var $iframe = toArray($('iframe[data-src]', $cur));
if ($iframe.length) {
$iframe.forEach(function(v) {
$iframe.forEach(function (v) {
var src = v.dataset.src;
v.src = src;
if (src) {
//防止二次加载
v.src = src;
delete v.dataset.src;
}
});

}
Expand All @@ -271,7 +275,7 @@
if (slideOutTimer) {
clearTimeout(slideOutTimer);
}
slideOutTimer = setTimeout(function() {
slideOutTimer = setTimeout(function () {
slideOutCallBack_(prev);
}, 1500);
}
Expand All @@ -287,7 +291,7 @@
cb && typeof cb === 'function' && proxyFn(cbNames, event);

//解绑事件:keypress,build
['Keypress', 'Build'].forEach(function(v) {
['Keypress', 'Build'].forEach(function (v) {
var callback = dataset['on' + v];
callback = getCallbackFuncFromName(callback);
if (callback && typeof callback === 'function') {
Expand All @@ -309,8 +313,8 @@
type = dataset.type,
url = dataset.url;
var fn = preloadFn['load' + type.toUpperCase()];
typeof fn === 'function' && fn(url, function(tmpNode) {
return function() {
typeof fn === 'function' && fn(url, function (tmpNode) {
return function () {
//将该标签删除,释放内存
tmpNode.parentNode && tmpNode.parentNode.removeChild(tmpNode);
tmpNode = null;
Expand Down Expand Up @@ -359,7 +363,7 @@
list.remove('tobuild');

if (list.contains('subSlide')) {
toArray($('.subSlide.builded', $curSlide)).forEach(function($item) {
toArray($('.subSlide.builded', $curSlide)).forEach(function ($item) {
$item.classList.add('subBuilded');
});
}
Expand Down Expand Up @@ -435,7 +439,7 @@

var $items = toArray($(buildClass, slide));
var dataset = slide.dataset;
$items.forEach(function($v, i) {
$items.forEach(function ($v, i) {
$v.classList.add('tobuild');
if (!('index' in $v.dataset)) {
$v.dataset.index = i;
Expand Down Expand Up @@ -545,7 +549,7 @@
}

var arr = ['next', 'past', 'far-next', 'far-past', 'current', 'pagedown', 'pageup'];
arr.forEach(function(v) {
arr.forEach(function (v) {
if (className !== v && pageClass !== v) {
el.classList.remove(v);
}
Expand All @@ -560,7 +564,7 @@
}
$slideTip.innerHTML = msg;
$slideTip.style.display = 'block';
setTimeout(function() {
setTimeout(function () {
$slideTip.style.display = 'none';
}, 3E3);
}
Expand Down Expand Up @@ -624,7 +628,7 @@
case 72:
// H: Toggle code highlighting
$doc.body.classList.toggle('highlight-code');
setTimeout(function() {
setTimeout(function () {
$doc.body.classList.toggle('highlight-code');
}, 2000);
break;
Expand Down Expand Up @@ -831,9 +835,9 @@
// $doc.addEventListener('keydown', evtkeydown, false); //j 防止页面走位
// $doc.addEventListener('keypress', evtkeydown, false); //j 防止页面走位
$body.addEventListener('touchstart', evtTouchStart, false);
$$('_btn-bar').addEventListener('click', function() {
$$('_btn-bar').addEventListener('click', function () {
var isOpen = false;
return function() {
return function () {
if (!isOpen) {
this.classList.remove('fa-bars');
this.classList.add('fa-close');
Expand All @@ -847,15 +851,15 @@
isOpen = !isOpen;
};
}(), false);
$$('_btn-prev').addEventListener('click', function() {
$$('_btn-prev').addEventListener('click', function () {
createKeyEvent(38);
}, false);
$$('_btn-next').addEventListener('click', function() {
$$('_btn-next').addEventListener('click', function () {
createKeyEvent(39);
}, false);
$$('_btn-overview').addEventListener('click', function() {
$$('_btn-overview').addEventListener('click', function () {
var isOpen = false;
return function() {
return function () {

if (isOpen) {
this.classList.add('fa-compress');
Expand All @@ -869,9 +873,9 @@
isOpen = !isOpen;
};
}(), false);
$$('_btn-brush').addEventListener('click', function() {
$$('_btn-brush').addEventListener('click', function () {
var isOpen = false;
return function() {
return function () {
if (isOpen) {
this.classList.add('fa-paint-brush');
this.classList.remove('fa-eraser');
Expand All @@ -885,7 +889,7 @@
};
}(), false);

$win.addEventListener('hashchange', function() {
$win.addEventListener('hashchange', function () {
if (location.hash && !lockSlide) {
doHash = false;
slideOutCallBack($slides[curIndex]);
Expand Down Expand Up @@ -963,7 +967,7 @@
}

//删除画板
var removePaint = function(isFromControl) {
var removePaint = function (isFromControl) {
clearPaint();
slideJump = ''; //j 幻灯片跳转
if (isControl) {
Expand All @@ -986,7 +990,7 @@
$B.fire('nodepptEvent:remove paint');
}
};
var pMouseDown = function(e) {
var pMouseDown = function (e) {
$drawBoard.isMouseDown = true;
try { //j 触屏画笔
var touch = e.targetTouches[0];
Expand All @@ -1003,7 +1007,7 @@
return false; //j 触屏画笔
};
var pPoints = [];
var pMouseUp = function(e) {
var pMouseUp = function (e) {
$drawBoard.isMouseDown = false;
$drawBoard.iLastX = -1;
$drawBoard.iLastY = -1;
Expand All @@ -1012,7 +1016,7 @@
}
pPoints.length = 0;
};
$B.on('controlEvent:paint points', function(data) {
$B.on('controlEvent:paint points', function (data) {
var points = data.points;
//远程来的屏幕
var wh = data.screen;
Expand Down Expand Up @@ -1041,7 +1045,7 @@
}
context.stroke();
});
var pMouseMove = function(e) {
var pMouseMove = function (e) {
var ee = e;
if ($drawBoard.isMouseDown) {
try { //j 触屏画笔
Expand Down Expand Up @@ -1121,7 +1125,7 @@
}

function fullImg() {
loadJS(defaultOptions.dir + 'img.screenfull.js', function() {
loadJS(defaultOptions.dir + 'img.screenfull.js', function () {
//图片处理
var $imgs = toArray($(defaultOptions.slideClass + ' img', $container));
screenfull($imgs);
Expand All @@ -1137,7 +1141,7 @@
//如果是print则需要修改
function iPrint() {
if (QUERY && QUERY.print) {
toArray($('iframe[data-src]')).forEach(function(v) {
toArray($('iframe[data-src]')).forEach(function (v) {
if (v.src.indexOf('about:blank') === 0 && v.dataset.src) {
v.src = v.dataset.src;
}
Expand All @@ -1155,7 +1159,7 @@
defaultOptions[key] = options[key];
}
}
['theme', 'transition'].forEach(function(v) {
['theme', 'transition'].forEach(function (v) {
if (QUERY && QUERY[v]) {
defaultOptions[v] = QUERY[v];
}
Expand All @@ -1164,7 +1168,7 @@
Slide.dir = defaultOptions.dir;
if (defaultOptions.control) {
var control = defaultOptions.control;
loadJS(defaultOptions.dir + 'nodeppt.control.js', function() {
loadJS(defaultOptions.dir + 'nodeppt.control.js', function () {
Slide.Control.load(control.type, control.args);
});
}
Expand Down Expand Up @@ -1237,7 +1241,7 @@
}
if (e.firstKiss) {
var $curSlide = $slides[index];
$curSlide.addEventListener(transitionEndEvent, function() {
$curSlide.addEventListener(transitionEndEvent, function () {
$cur.style.visibility = 'visible';
});
}
Expand Down Expand Up @@ -1266,7 +1270,7 @@


}
magic.init = function(e) {
magic.init = function (e) {
var $cur = $('.magic', e.container);
if ($cur.length) {
$cur = $cur[0];
Expand Down Expand Up @@ -1295,7 +1299,7 @@
current: 0,
curItem: 0,
init: init,
setIndex: function(i, item) {
setIndex: function (i, item) {
i--;
if (i < 0) {
i = 0;
Expand Down Expand Up @@ -1325,8 +1329,8 @@
buildPrevItem: buildPrevItem,
magic: magic
};
['on', 'un', 'fire'].forEach(function(v) {
Slide[v] = function() {
['on', 'un', 'fire'].forEach(function (v) {
Slide[v] = function () {
var args = toArray(arguments);
args[0] = 'slide.' + args[0];
$B[v].apply(null, args);
Expand Down
Loading

0 comments on commit 6fc22a4

Please sign in to comment.