Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scrollToPercent(pos) {
- const
- { refElSizes } = this.state,
- { secondLayerOnly, firstLayerOnly, firstLayerWithScales } = this.refs,
- firstLayerOnlyWidth = firstLayerOnly.getBoundingClientRect().width,
- firstLayerWithScalesWidth = firstLayerWithScales.getBoundingClientRect().width,
- scaleDiff = firstLayerWithScalesWidth - firstLayerOnlyWidth,
- clickPercentage = (pos.x - scaleDiff) / firstLayerOnlyWidth,
- secondLayerWidth = refElSizes.layers.second.width * this.secondLayerMultiplier,
- scrollLevel = secondLayerOnly.parentNode,
- layersDiff = secondLayerWidth - refElSizes.layers.first.width,
- answer = layersDiff * clickPercentage;
- scrollLevel.scrollLeft = answer;
- }
- /*<layers*/
- /*nodes>*/
- firstLayerNodeClick(e, level, id) {
- const
- pos = {x: e.clientX, y: e.clientY};
- this.scrollToPercent(pos);
- this.changeLevel(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement