Advertisement
sergeuniquite

Exchange

Nov 2nd, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     scrollToPercent(pos) {
  2.         const
  3.             { refElSizes } = this.state,
  4.             { secondLayerOnly, firstLayerOnly, firstLayerWithScales } = this.refs,
  5.             firstLayerOnlyWidth = firstLayerOnly.getBoundingClientRect().width,
  6.             firstLayerWithScalesWidth = firstLayerWithScales.getBoundingClientRect().width,
  7.             scaleDiff = firstLayerWithScalesWidth - firstLayerOnlyWidth,
  8.             clickPercentage = (pos.x - scaleDiff) / firstLayerOnlyWidth,
  9.             secondLayerWidth = refElSizes.layers.second.width * this.secondLayerMultiplier,
  10.             scrollLevel = secondLayerOnly.parentNode,
  11.             layersDiff = secondLayerWidth - refElSizes.layers.first.width,
  12.             answer = layersDiff * clickPercentage;
  13.  
  14.         scrollLevel.scrollLeft = answer;
  15.     }
  16.     /*<layers*/
  17.    
  18.     /*nodes>*/
  19.     firstLayerNodeClick(e, level, id) {
  20.         const
  21.             pos = {x: e.clientX, y: e.clientY};
  22.        
  23.         this.scrollToPercent(pos);
  24.         this.changeLevel(true);
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement