Skip to content

Commit 5324992

Browse files
committed
Updated to newest master with the performance increasement.
1 parent 7feff9c commit 5324992

File tree

2 files changed

+48
-30
lines changed

2 files changed

+48
-30
lines changed

build/js/app.js

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,14 @@
471471
var domLoaded = function (callback) {
472472
/* Internet Explorer */
473473
/*@cc_on
474-
@if (@_win32 || @_win64)
475-
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
476-
document.getElementById('ieScriptLoad').onreadystatechange = function() {
477-
if (this.readyState == 'complete') {
478-
callback();
479-
}
480-
};
481-
@end @*/
474+
@if (@_win32 || @_win64)
475+
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
476+
document.getElementById('ieScriptLoad').onreadystatechange = function() {
477+
if (this.readyState == 'complete') {
478+
callback();
479+
}
480+
};
481+
@end @*/
482482
/* Mozilla, Chrome, Opera */
483483
if (document.addEventListener) {
484484
document.addEventListener('DOMContentLoaded', callback, false);
@@ -509,7 +509,6 @@
509509
ElementQueries.listen();
510510
}
511511
})();
512-
513512
}).call(this,require("g5I+bs"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/css-element-queries/src/ElementQueries.js","/css-element-queries/src")
514513
},{"./ResizeSensor":2,"buffer":5,"g5I+bs":14}],2:[function(require,module,exports){
515514
(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){
@@ -521,6 +520,13 @@
521520
;
522521
(function() {
523522

523+
var requestAnimationFrame = window.requestAnimationFrame ||
524+
window.mozRequestAnimationFrame ||
525+
window.webkitRequestAnimationFrame ||
526+
function (fn) {
527+
return window.setTimeout(fn, 20);
528+
};
529+
524530
/**
525531
* Class for dimension change detection.
526532
*
@@ -599,29 +605,47 @@
599605
var expand = element.resizeSensor.childNodes[0];
600606
var expandChild = expand.childNodes[0];
601607
var shrink = element.resizeSensor.childNodes[1];
602-
var shrinkChild = shrink.childNodes[0];
603-
604-
var lastWidth, lastHeight;
605608

606609
var reset = function() {
607-
expandChild.style.width = expand.offsetWidth + 10 + 'px';
608-
expandChild.style.height = expand.offsetHeight + 10 + 'px';
609-
expand.scrollLeft = expand.scrollWidth;
610-
expand.scrollTop = expand.scrollHeight;
611-
shrink.scrollLeft = shrink.scrollWidth;
612-
shrink.scrollTop = shrink.scrollHeight;
613-
lastWidth = element.offsetWidth;
614-
lastHeight = element.offsetHeight;
610+
expandChild.style.width = 100000 + 'px';
611+
expandChild.style.height = 100000 + 'px';
612+
613+
expand.scrollLeft = 100000;
614+
expand.scrollTop = 100000;
615+
616+
shrink.scrollLeft = 100000;
617+
shrink.scrollTop = 100000;
615618
};
616619

617620
reset();
621+
var dirty = false;
618622

619-
var changed = function() {
620-
if (element.resizedAttached) {
623+
var dirtyChecking = function() {
624+
if (!element.resizedAttached) return;
625+
626+
if (dirty) {
621627
element.resizedAttached.call();
628+
dirty = false;
622629
}
630+
631+
requestAnimationFrame(dirtyChecking);
632+
};
633+
634+
requestAnimationFrame(dirtyChecking);
635+
var lastWidth, lastHeight;
636+
var cachedWidth, cachedHeight; //useful to not query offsetWidth twice
637+
638+
var onScroll = function() {
639+
if ((cachedWidth = element.offsetWidth) != lastWidth || (cachedHeight = element.offsetHeight) != lastHeight) {
640+
dirty = true;
641+
642+
lastWidth = cachedWidth;
643+
lastHeight = cachedHeight;
644+
}
645+
reset();
623646
};
624647

648+
625649
var addEvent = function(el, name, cb) {
626650
if (el.attachEvent) {
627651
el.attachEvent('on' + name, cb);
@@ -630,13 +654,6 @@
630654
}
631655
};
632656

633-
var onScroll = function() {
634-
if (element.offsetWidth != lastWidth || element.offsetHeight != lastHeight) {
635-
changed();
636-
}
637-
reset();
638-
};
639-
640657
addEvent(expand, 'scroll', onScroll);
641658
addEvent(shrink, 'scroll', onScroll);
642659
}
@@ -838,7 +855,7 @@ function example5(){
838855
box[0].innerHTML = (++changed) + ' changes. ' + box.parent()[0].clientWidth+'px/'+box.parent()[0].clientHeight+'px';
839856
});
840857
}
841-
}).call(this,require("g5I+bs"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_cb029744.js","/")
858+
}).call(this,require("g5I+bs"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_fa898b42.js","/")
842859
},{"./css-element-queries/src/ElementQueries":1,"./css-element-queries/src/ResizeSensor":2,"buffer":5,"codemirror/lib/codemirror":6,"codemirror/mode/css/css":7,"codemirror/mode/htmlmixed/htmlmixed":8,"codemirror/mode/javascript/javascript":9,"codemirror/mode/xml/xml":10,"g5I+bs":14,"hammerjs/hammer":11,"jQuery":13}],4:[function(require,module,exports){
843860
(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){
844861
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"bootstrap": "^3.3.6",
1212
"codemirror": "^5.11.0",
13+
"gulp": "^3.9.0",
1314
"gulp-browserify": "^0.5.1",
1415
"gulp-concat": "^2.6.0",
1516
"gulp-markdown": "^1.2.0",

0 commit comments

Comments
 (0)