This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WsStateDisconnected = 0; | |
const WsStateDisconnecting = 1; | |
const WsStateConnected = 2; | |
const WsStateConnecting = 3; | |
class SimpleWSocket { | |
constructor(url) { | |
this.wsState = WsStateDisconnected; | |
this.timer = null; | |
this.url = url; | |
this.ws = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scrolledIntoView(element) { | |
var rect = element.getBoundingClientRect() | |
, h = (window.innerHeight || document.documentElement.clientHeight) | |
, w = (window.innerWidth || document.documentElement.clientWidth) | |
, verticalVisibility = (rect.top <= h) && ((rect.top + rect.height) >= 0) | |
, horizontalVisibility = (rect.left <= w) && ((rect.left + rect.width) >= 0) | |
return verticalVisibility && horizontalVisibility | |
} |