Archived
0

MCSM:WebConsole: несколько исправлений функционала скроллинга

This commit is contained in:
2017-06-07 14:26:49 +03:00
parent 8e361fab2b
commit e8084f5d45
2 changed files with 17 additions and 0 deletions

View File

@@ -81,10 +81,17 @@ var ScrollingContent = React.createClass({
this.ownHeight = this.refs.content.clientHeight;
this.scrollRatio = this.ownHeight / this.totalHeight;
if (isNaN(this.scrollRatio)) this.scrollRatio = 0;
this.refs.scroll.style.height = this.scrollRatio * 100 + "%";
this.refs.scroll.style.top = (this.refs.content.scrollTop / this.totalHeight) * 100 + "%";
},
toggleSelect: function (value, event) { return value; },
handleScrollMouseDown: function (event) {
this.lastPageY = event.pageY;
document.body.classList.add('scroll-grabbed');
this.refs.scroll.classList.add('scroll-grabbed');
document.onselectstart = this.toggleSelect.bind(null, false);
document.addEventListener('mousemove', this.handleScrollMouseMove);
document.addEventListener('mouseup', this.handleScrollMouseUp);
},
@@ -99,6 +106,10 @@ var ScrollingContent = React.createClass({
});
},
handleScrollMouseUp: function (event) {
document.body.classList.remove('scroll-grabbed');
this.refs.scroll.classList.remove('scroll-grabbed');
document.onselectstart = this.toggleSelect.bind(null, true);
document.removeEventListener('mousemove', this.handleScrollMouseMove);
document.removeEventListener('mouseup', this.handleScrollMouseUp);
},

View File

@@ -36,6 +36,12 @@
right: 0;
}
.scroll-grabbed,
.scroll-grabbed * {
cursor: -webkit-grabbing !important;
cursor: -moz-grabbing !important;
}
#webconsole input {
background-color: #1e1e1e;
background-image: url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="30"><text x="7" y="24" style="font-size: 1.5em; font-family: monospace" fill="#ffffff">&gt;</text></svg>');