@fusioncharts/core
Version:
JavaScript Data Visualisation Library
1 lines • 4.67 kB
JavaScript
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _tool=_interopRequireDefault(require("../tool"));var _dependencyManager=require("../../../dependency-manager");var _schedular=require("../../../schedular");var _lib=require("../../../../src/lib");var R=(0,_dependencyManager.getDep)("redraphael","plugin"),mathMax=Math.max;var ScrollTrack=function(_Tool){function ScrollTrack(){var _this;_this=_Tool.call(this)||this;_this.updateColor=function(){return R.tintshade.apply(R,arguments).rgba};_this._evtHandlers={};return _this}(0,_inheritsLoose2.default)(ScrollTrack,_Tool);var _proto=ScrollTrack.prototype;_proto.configureAttributes=function configureAttributes(obj){if(obj===void 0){obj={}}var selfConfig=this.config,scrollbar=this.getLinkedParent(),scrollbarConfig=scrollbar.config,useLegendScrollGradient=scrollbarConfig.useLegendScrollGradient,legendTrackColor=scrollbarConfig.legendScrollTrackColor,defaultGradientColor=[90*obj.isHorizontal,R.tintshade(obj.color,.15).rgba,obj.color],solidTrackFill=legendTrackColor!=null?legendTrackColor:obj.displayFlat?obj.color:defaultGradientColor.join("-"),gradientTrackFill=useLegendScrollGradient?[legendTrackColor.angle,legendTrackColor.startcolor,legendTrackColor.endcolor].join("-"):legendTrackColor;selfConfig.style={track:Object.assign({},{fill:useLegendScrollGradient?gradientTrackFill:solidTrackFill,stroke:scrollbarConfig.legendTrackStrokeBorderColor?scrollbarConfig.legendTrackStrokeBorderColor:R.tintshade(obj.color,-.75).rgba},obj.style.track)}};_proto.attachEventHandlers=function attachEventHandlers(){var scrollTrack=this,selfConfig=scrollTrack.config,scrollbar=scrollTrack.getLinkedParent(),scrollbarConfig=scrollbar.config,diff,continueDrag,posDisplacement,scrollAnchor,scrollAnchorConfig,boundaryCheckandDraw=function boundaryCheckandDraw(){if(scrollbarConfig.scrollPosition>1){scrollbarConfig.scrollPosition=1;continueDrag=false}else if(scrollbarConfig.scrollPosition<0||isNaN(scrollbarConfig.scrollPosition)){scrollbarConfig.scrollPosition=0;continueDrag=false}scrollAnchor.asyncDraw();typeof scrollbarConfig.evt.scroll==="function"&&scrollbarConfig.evt.scroll(scrollbarConfig.scrollPosition)},_dragRightJob=function dragRightJob(){scrollbarConfig.scrollPosition+=.01;if(posDisplacement>=scrollbarConfig.scrollPosition&&continueDrag){boundaryCheckandDraw();scrollTrack.addJob("dragScrollAnchorRight",_dragRightJob,_schedular.priorityList.draw)}},_dragLeftJob=function dragLeftJob(){scrollbarConfig.scrollPosition-=.01;if(posDisplacement<=scrollbarConfig.scrollPosition&&continueDrag){boundaryCheckandDraw();scrollTrack.addJob("dragScrollAnchorLeft",_dragLeftJob,_schedular.priorityList.draw)}};scrollTrack.addEventListener("fc-mousedown",scrollTrack._evtHandlers.mousedown||(scrollTrack._evtHandlers.mousedown=function(event){scrollAnchor=scrollbar.getChildren("scrollAnchor")[0];scrollAnchorConfig=scrollAnchor.config;continueDrag=true;if(scrollbarConfig.isHorizontal){diff=event.originalEvent.layerX-(scrollAnchorConfig._nodeDimensions.x+selfConfig.transLateX+scrollAnchorConfig._nodeDimensions.width/2)}else{diff=event.originalEvent.layerY-(scrollAnchorConfig._nodeDimensions.y+selfConfig.transLateY+scrollAnchorConfig._nodeDimensions.height/2)}posDisplacement=diff/scrollAnchorConfig.trackLength+scrollbarConfig.scrollPosition;if(posDisplacement>=scrollbarConfig.scrollPosition){scrollTrack.addJob("dragScrollAnchorRight",_dragRightJob,_schedular.priorityList.draw)}else{scrollTrack.addJob("dragScrollAnchorLeft",_dragLeftJob,_schedular.priorityList.draw)}}));scrollTrack.addEventListener("fc-mouseup",scrollTrack._evtHandlers.mouseup||(scrollTrack._evtHandlers.mouseup=function(){scrollbarConfig.evt.scrollEnd();continueDrag=false}))};_proto.draw=function draw(){var scrollTrack=this,selfConfig=scrollTrack.config,scrollbar=this.getLinkedParent(),scrollbarConfig=scrollbar.config,newScroll=(0,_lib.crispBound)(scrollbarConfig.x+.5,scrollbarConfig.y+scrollbarConfig.padding+.5,scrollbarConfig.width-1,scrollbarConfig.height-1,scrollbarConfig.strokeWidth);scrollTrack.addGraphicalElement({el:"rect",attr:{x:newScroll.x,y:newScroll.y,width:mathMax(newScroll.width,0),height:mathMax(newScroll.height,0),r:scrollbarConfig.roundEdges&&2||0,opacity:selfConfig.style.track.opacity},css:selfConfig.style.track,container:{id:"scrollbarGroup",label:"scrollbarGroup",isParent:true},component:scrollTrack,label:"scrollbarTrack",id:"scrollbarTrack"})};return ScrollTrack}(_tool.default);var _default=exports.default=ScrollTrack;
;