📄 animation.js
字号:
styleHandle.visibility = isc.Canvas.VISIBLE; styleHandle.visibility = isc.Canvas.INHERIT; info._toggledVis = true; } if (ratio == 1) { delete this.$fadeAnimationInfo; delete this.fadeAnimation; } this.setOpacity(opacity, (ratio < 1)); if (ratio == 1) this._fireAnimationCompletionCallback(info._callback, earlyFinish); }, //> @method canvas.animateScroll() // Animate a scroll from the current scroll position to the specified position. // @param scrollLeft (number) desired final left scroll postion // @param scrollTop (number) desired final top scroll postion // @param [callback] (callback) When the scroll completes this callback will be fired. Single // 'earlyFinish' parameter will be passed if the animation was // cut short by a call to finishAnimation // @param [duration] (number) Duration in ms of the animated scroll // @param [acceleration] (AnimationAcceleration) Optional acceleration to bias the animation ratios // @visibility animation // @group animation //< animateScroll : function (scrollLeft, scrollTop, callback, duration, acceleration) { var overflow = this.overflow; if (this.overflow == isc.Canvas.VISIBLE) return; var info = {_fromLeft:this.getScrollLeft(), _fromTop:this.getScrollTop(), _toLeft:scrollLeft, _toTop:scrollTop, _callback:callback}; return this._startAnimation("scroll", info, duration, acceleration); }, fireAnimationScroll : function (ratio, ID, earlyFinish) { var info = this.$scrollAnimationInfo, fromLeft = info._fromLeft, toLeft = info._toLeft, fromTop = info._fromTop, toTop = info._toTop, newLeft = this._getRatioTargetValue(fromLeft, toLeft, ratio), newTop = this._getRatioTargetValue(fromTop, toTop, ratio); if (ratio == 1) { delete this.$scrollAnimationInfo; delete this.scrollAnimation; } this.scrollTo(newLeft, newTop, null, (ratio < 1)); if (ratio ==1 && info._callback) { this._fireAnimationCompletionCallback(info._callback, earlyFinish); } }, //> @method canvas.animateShow() // Show a canvas by growing it vertically to its fully drawn height over a period of time. // This method will not fire if the widget is already drawn and visible, or has overflow // other than <code>"visible"</code> or <code>"hidden"</code>. // @param effect (string | object) // How should the content of the window be revealed during the show. // Supported effects are <ul> // <li><code>"slide"</code> (content slides into view as the window grows) // <li><code>"wipe"</code> (default: content is revealed as the window grows) // <li><code>"fade"</code> (widget fades into view, from transparent // to widget's specified <code>opacity</code> // - 100% by default) // <li><code>"fly"</code> (widget is moved to its final position from // an offscreen position to the left) // </ul> // If passed an object, the <code>effect</code> attribute of the object should be // one of the above effect strings - other attributes may be used to modify the effect // Currently this is only supported for <code>"slide"</code> and <code>"wipe"</code> // type animations where <code>"startFrom"</code> may be specified as <code>"T"</code> // [the animation will shift the widget down from the top] or <code>"L"</code> [the // animation will grow the widget from the left side]. // @param [callback] (callback) When the show completes this callback will be fired. Single // 'earlyFinish' parameter will be passed if the animation was // cut short by a call to finishAnimation. // @param [duration] (number) Duration in ms of the animated show // @param [acceleration] (AnimationAcceleration) Optional acceleration effect function to // bias the animation ratios // @visibility animation // @group animation // @example animateWipe //< _$show:"show", _$slide:"slide", _$wipe:"wipe", _$fade:"fade", _$fly:"fly", _$T:"T", _$L:"L", _showEffectAnimationMap:{slide:"show", wipe:"show", fly:"move", fade:"fade"}, animateShow : function (effect, callback, duration, acceleration) { var effectConfig; if (isc.isAn.Object(effect)) { effectConfig = effect; effect = effect.effect; } // If we're in the process of doing an animateHide(), finish that before we do the // animateShow() - this is required to avoid a no-op due to the fact that the widget // is currently drawn/visible. if (this._animatingHide != null) this.finishAnimation(this._animatingHide); // Could fire callback if it's already showing? if (this.isDrawn() && this.isVisible()) return; // Also - if we're in mid 'animateShow()' just bail if (this._animatingShow != null) return; // animateShow() / animateHide() fall through to various methods to perform the actual // animation based on the effect passed in. // This means we can't just check 'this.isAnimating("show")' or 'this.isAnimating("hide")' // - the animation may be performed via a move or fade. // Add a flag at the beginning of animateShow() / animateHide() so we can readily check // for the case where we're in this state. // Also - always fire an "animateShowComplete()" callback when the show/hide completes // this allows us to clear the flag before firing whatever callback was passed into // this method. this._animatingShow = this._showEffectAnimationMap[effect] || this._$show; this._animateShowCallback = callback; if (!this._animateShowCompleteCallback) this._animateShowCompleteCallback = {target:this, methodName:"animateShowComplete"} if (effect == this._$fade) { var targetOpacity = this.opacity; this._fadeShowCallback = callback; this.setOpacity(0); this.show(); // Explicitly default to animateShowTime / animateShowAcceleration rather than // falling through to animateFadeTime / Acceleration if (duration == null) duration = this.animateShowTime; if (acceleration == null) acceleration = this.animateShowAcceleration; // Simply fall through to animate fade, then fire the callback on completion. return this.animateFade(targetOpacity, this._animateShowCompleteCallback, duration, acceleration); } else if (effect == this._$fly) { if (this.parentElement != null) { this.logInfo("animateShow() called with 'fly' effect - not supported for child widgets" + " defaulting to standard 'wipe' animation instead.", "animation"); effect = this._$wipe; } else { // Explicitly default to animateShowTime / animateShowAcceleration rather than // falling through to animateMoveTime / Acceleration if (duration == null) duration = this.animateShowTime; if (acceleration == null) acceleration = this.animateShowAcceleration; // Simply fall through to animate move, then fire the callback on completion. var rtl = this.isRTL(), specifiedLeft = this.getLeft(), offscreenLeft = rtl ? isc.Page.getWidth() + isc.Page.getScrollLeft() : 0 - this.getVisibleWidth(); this.setLeft(offscreenLeft); this.show(); return this.animateMove(specifiedLeft, null, this._animateShowCompleteCallback, duration, acceleration); } } // If we can't animate the show, just show and fire callback if (!this._canAnimateClip(effect)) { this.logInfo("not animating show, can't do clip animations", "animation"); this.show(); // essentially this is an 'early finish' if (callback) this.animateShowComplete(true); return; } // Start from drawn / hidden - this way we can get the drawn scrollHeight. if (this.isVisible()) this.hide(); // If we're undrawn, draw() if _drawOnShow() is true - true for top level widgets // that are not peers. // Otherwise fall through to default 'show()' method to show [without drawing] // immediately if (!this.isDrawn()) { if (this.parentElement && !this.parentElement.isDrawn()) { this.show(); this.logInfo("not animating show, component not drawn", "animation"); // again - this is an 'early finish' if (callback) this.animateShowComplete(true); return; } else { this.draw(); } } var drawnHeight = this.getVisibleHeight(), drawnWidth = this.getVisibleWidth(), // default to showing from the top down // Note that we currently just support top down or left in so convert this to a // boolean for simplicity vertical = effectConfig ? effectConfig.startFrom == this._$T : true, scrollStart = (vertical ? this.getScrollTop() : this.getScrollLeft()), slideIn = (effect == "slide"), info = { _userHeight:this._userHeight, _specifiedHeight:this.getHeight(), _drawnHeight:drawnHeight, _userWidth:this._userWidth, _specifiedWidth:this.getWidth(), _drawnWidth:drawnWidth, _originalOverflow:this.overflow, _vertical:vertical, _scrollStart:scrollStart, _slideIn:slideIn, _callback:this._animateShowCompleteCallback }; if (vertical) { if (this.vscrollOn && this.vscrollbar) { info._scrollThumbStart = this.vscrollbar.thumb.getTop(); info._scrollThumbLength = this.vscrollbar.thumb.getHeight(); // don't show the thumb with the s-b - we'll show it and grow it into view if (this.vscrollbar.thumb) { this.vscrollbar.thumb._showWithMaster = false; this.vscrollbar.thumb._suppressImageResize = true; } this.vscrollbar._suppressSetThumb = true; this.vscrollbar._suppressImageResize = true; // resize the scrollbar to be 1px so it doesn't flash when first shown this.vscrollbar.setHeight(1); } if (this.hscrollOn && this.hscrollbar) { this.hscrollbar._suppressImageResize = true; if (this.hscrollbar.thumb) this.hscrollbar.thumb._suppressImageResize = true; // If we're doing a wipe, we won't show the breadth scrollbar until // the rest of the widget has been 'wiped' into view if (!info._slideIn) { this.hscrollbar._showWithMaster = false; } else { this.hscrollbar.setTop(this.getTop()); this.hscrollbar.setHeight(1); } } } else { if (this.hscrollOn && this.hscrollbar) { info._scrollThumbStart = this.hscrollbar.thumb.getLeft(); info._scrollThumbLength = this.hscrollbar.thumb.getWidth(); this.hscrollbar._suppressSetThumb = true; this.hscrollbar._suppressImageResize = true; // don't show the thumb with the s-b - we'll show it and grow it into view if (this.hscrollbar.thumb) { this.hscrollbar.thumb._showWithMaster = false; this.hscrollbar.thumb._suppressImageResize = true; } this.hscrollbar.setWidth(1); } if (this.vscrollOn && this.vscrollbar) { this.vscrollbar._suppressImageResize = true; if (this.vscrollbar.thumb) this.vscrollbar.thumb._suppressImageResize = true; // If we're doing a wipe, we won't show the breadth scrollbar until // the rest of the widget has been 'wiped' into view if (!info._slideIn) { this.vscrollbar._showWithMaster = false; } else { this.vscrollbar.setLeft(this.getLeft()); this.vscrollbar.setWidth(1); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -