git.haldean.org sousvide / 7b92e2f
Add ability to disable animations for slower platforms Will Haldean Brown 6 years ago
2 changed file(s) with 27 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
00 var targetInputElem, displayToggle, editorElem;
11 var editorVisible = false;
2
3 function swapClasses(elemId, start, end) {
4 if (animEnabled) {
5 d3.select(elemId)
6 .transition()
7 .style('opacity', '0')
8 .each('end', function() {
9 d3.select(elemId)
10 .classed(start, false)
11 .classed(end, true)
12 .transition().style('opacity', '1');
13 });
14 } else {
15 d3.select(elemId).classed(start, false).classed(end, true);
16 }
17 }
218
319 function initEditor() {
420 targetInputElem = document.getElementById("target_input");
1026 if (editorVisible) {
1127 d3.select('#editor').style('margin-left', '0px')
1228 .transition().style('margin-left', '-300px').duration(500);
13 d3.select('#editor_expand')
14 .transition()
15 .style('opacity', '0')
16 .each('end', function() {
17 d3.select('#editor_expand')
18 .classed("icon-double-angle-right", true)
19 .classed("icon-double-angle-left", false)
20 .transition().style('opacity', '1');
21 });
29 swapClasses('#editor_expand', 'icon-double-angle-left', 'icon-double-angle-right');
2230 } else {
2331 d3.select('#editor').style('margin-left', '-300px')
2432 .transition().style('margin-left', '0px').duration(500);
25 d3.select('#editor_expand')
26 .transition()
27 .style('opacity', '0')
28 .each('end', function() {
29 d3.select('#editor_expand')
30 .classed("icon-double-angle-left", true)
31 .classed("icon-double-angle-right", false)
32 .transition().style('opacity', '1');
33 });
33 swapClasses('#editor_expand', 'icon-double-angle-right', 'icon-double-angle-left');
3434 }
3535 editorVisible = !editorVisible;
3636 });
44
55 var mask;
66 var maskHidden = true;
7
8 var animEnabled = true;
9
10 function disableAnim(){
11 animEnabled = false;
12 d3.selection.prototype.duration = function(){ return this; }
13 d3.selection.prototype.transition = function(){ return this; }
14 d3.selection.prototype.ease = function() { return this; }
15 }
716
817 function hideMask() {
918 if (maskHidden) return;