|
385 | 385 | LiveReload.prototype.performReload = function(message) { |
386 | 386 | var _ref, _ref1; |
387 | 387 | this.log("LiveReload received reload request: " + (JSON.stringify(message, null, 2))); |
388 | | - return this.reloader.reload(message.path, { |
| 388 | + this.reloader.reload(message.path, { |
389 | 389 | liveCSS: (_ref = message.liveCSS) != null ? _ref : true, |
390 | 390 | liveImg: (_ref1 = message.liveImg) != null ? _ref1 : true, |
391 | 391 | originalPath: message.originalPath || '', |
392 | 392 | overrideURL: message.overrideURL || '', |
393 | | - serverURL: "http://" + this.options.host + ":" + this.options.port |
| 393 | + serverURL: "//" + this.options.host + ":" + this.options.port |
394 | 394 | }); |
| 395 | + return this.performTransition(); |
395 | 396 | }; |
396 | 397 |
|
397 | 398 | LiveReload.prototype.performAlert = function(message) { |
398 | 399 | return alert(message.message); |
399 | 400 | }; |
400 | 401 |
|
| 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 | + |
401 | 413 | LiveReload.prototype.shutDown = function() { |
402 | 414 | var _base; |
403 | 415 | this.connector.disconnect(); |
|
450 | 462 | }); |
451 | 463 | }; |
452 | 464 |
|
| 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 | + |
453 | 483 | return LiveReload; |
454 | 484 |
|
455 | 485 | })(); |
|
470 | 500 | this.mindelay = 1000; |
471 | 501 | this.maxdelay = 60000; |
472 | 502 | this.handshake_timeout = 5000; |
| 503 | + this.animate = false; |
| 504 | + this.animation_duration = 280; |
473 | 505 | } |
474 | 506 |
|
475 | 507 | Options.prototype.set = function(name, value) { |
|
1095 | 1127 | }); |
1096 | 1128 |
|
1097 | 1129 | LiveReload.on('connect', function() { |
| 1130 | + if (!!/true|1$/.test(LiveReload.options.animate)) { |
| 1131 | + LiveReload.setUpCSSTransitions(); |
| 1132 | + } |
1098 | 1133 | return CustomEvents.fire(document, 'LiveReloadConnect'); |
1099 | 1134 | }); |
1100 | 1135 |
|
|
0 commit comments