Commit 1ee464f5 authored by Vadim Makeev's avatar Vadim Makeev

Merge pull request #156 from anton-ryzhov/event_handlers

Don't call iterate DOM several times in event handlers
parents 34ac2127 79f12125
...@@ -42,7 +42,7 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -42,7 +42,7 @@ window.shower = window.shower || (function(window, document, undefined) {
}, },
isLast : function() { isLast : function() {
return shower.slideList.length === this.number + 1 return shower.slideList.length === this.number + 1;
}, },
/** /**
...@@ -889,11 +889,13 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -889,11 +889,13 @@ window.shower = window.shower || (function(window, document, undefined) {
shower.init(); shower.init();
document.addEventListener('click', function(e) { document.addEventListener('click', function(e) {
var slideNumber = shower.getSlideNumber(shower._getSlideIdByEl(e.target)), var slideId = shower._getSlideIdByEl(e.target),
slideNumber,
slide; slide;
// Click on slide in List mode // Click on slide in List mode
if (shower.isListMode() && shower._getSlideIdByEl(e.target)) { if (slideId && shower.isListMode()) {
slideNumber = shower.getSlideNumber(slideId);
// Warning: go must be before enterSlideMode. // Warning: go must be before enterSlideMode.
// Otherwise there is a bug in Chrome // Otherwise there is a bug in Chrome
shower.go(slideNumber); shower.go(slideNumber);
...@@ -908,11 +910,12 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -908,11 +910,12 @@ window.shower = window.shower || (function(window, document, undefined) {
}, false); }, false);
document.addEventListener('touchstart', function(e) { document.addEventListener('touchstart', function(e) {
var slideNumber = shower.getSlideNumber(shower._getSlideIdByEl(e.target)), var slideId = shower._getSlideIdByEl(e.target),
slideNumber,
slide, slide,
x; x;
if (shower._getSlideIdByEl(e.target)) { if (slideId) {
if (shower.isSlideMode() && ! shower._checkInteractiveElement(e)) { if (shower.isSlideMode() && ! shower._checkInteractiveElement(e)) {
x = e.touches[0].pageX; x = e.touches[0].pageX;
...@@ -924,9 +927,10 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -924,9 +927,10 @@ window.shower = window.shower || (function(window, document, undefined) {
} }
if (shower.isListMode()) { if (shower.isListMode()) {
slideNumber = shower.getSlideNumber(slideId);
// Warning: go must be before enterSlideMode. // Warning: go must be before enterSlideMode.
// Otherwise there is a bug in Chrome // Otherwise there is a bug in Chrome
shower.go(shower.getSlideNumber(shower._getSlideIdByEl(e.target))); shower.go(slideNumber);
shower.enterSlideMode(); shower.enterSlideMode();
shower.showPresenterNotes(slideNumber); shower.showPresenterNotes(slideNumber);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment