Skip to content

Commit 8ca0340

Browse files
committed
Rebuild JS
1 parent f049dbb commit 8ca0340

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

dist/livereload.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,31 @@
385385
LiveReload.prototype.performReload = function(message) {
386386
var _ref, _ref1;
387387
this.log("LiveReload received reload request: " + (JSON.stringify(message, null, 2)));
388-
return this.reloader.reload(message.path, {
388+
this.reloader.reload(message.path, {
389389
liveCSS: (_ref = message.liveCSS) != null ? _ref : true,
390390
liveImg: (_ref1 = message.liveImg) != null ? _ref1 : true,
391391
originalPath: message.originalPath || '',
392392
overrideURL: message.overrideURL || '',
393-
serverURL: "http://" + this.options.host + ":" + this.options.port
393+
serverURL: "//" + this.options.host + ":" + this.options.port
394394
});
395+
return this.performTransition();
395396
};
396397

397398
LiveReload.prototype.performAlert = function(message) {
398399
return alert(message.message);
399400
};
400401

402+
LiveReload.prototype.performTransition = function() {
403+
var existingHtmlClass, html, reloadedClass, _ref;
404+
html = document.body.parentNode;
405+
reloadedClass = ' livereload-reloaded ';
406+
existingHtmlClass = (_ref = html.getAttribute('class')) != null ? _ref : '';
407+
html.setAttribute('class', "" + (existingHtmlClass.replace(reloadedClass, '')) + " " + reloadedClass);
408+
return setTimeout((function() {
409+
return html.setAttribute('class', existingHtmlClass.replace(reloadedClass, ''));
410+
}), parseInt(this.options.animation_duration, 10) + 20);
411+
};
412+
401413
LiveReload.prototype.shutDown = function() {
402414
var _base;
403415
this.connector.disconnect();
@@ -450,6 +462,24 @@
450462
});
451463
};
452464

465+
LiveReload.prototype.setUpCSSTransitions = function() {
466+
var cssText, head, prefixer, styleNode;
467+
prefixer = function(declaration) {
468+
return (['-webkit-', '-moz-', ''].map(function(item) {
469+
return "" + item + declaration;
470+
})).join(' ');
471+
};
472+
head = document.getElementsByTagName('head')[0];
473+
styleNode = document.createElement("style");
474+
cssText = ".livereload-reloaded * { " + (prefixer('transition: all ' + this.options.animation_duration + 'ms ease-out;')) + " }";
475+
if (styleNode.styleSheet) {
476+
styleNode.styleSheet.cssText = cssText;
477+
} else {
478+
styleNode.appendChild(document.createTextNode(cssText));
479+
}
480+
return head.appendChild(styleNode);
481+
};
482+
453483
return LiveReload;
454484

455485
})();
@@ -470,6 +500,8 @@
470500
this.mindelay = 1000;
471501
this.maxdelay = 60000;
472502
this.handshake_timeout = 5000;
503+
this.animate = false;
504+
this.animation_duration = 280;
473505
}
474506

475507
Options.prototype.set = function(name, value) {
@@ -1095,6 +1127,9 @@
10951127
});
10961128

10971129
LiveReload.on('connect', function() {
1130+
if (!!/true|1$/.test(LiveReload.options.animate)) {
1131+
LiveReload.setUpCSSTransitions();
1132+
}
10981133
return CustomEvents.fire(document, 'LiveReloadConnect');
10991134
});
11001135

0 commit comments

Comments
 (0)