📄 animation.js
字号:
// If we have a visible edged canvas suppress react to resize before we set overflow // to hidden or resize the handle so the edged canvas doesn't get resized as a peer if (this.showEdges && this._edgedCanvas) { this._edgedCanvas._suppressReactToResize = true; } // Set overflow to hidden, then grow to the drawn size (and then reset overflow) if (this.overflow == isc.Canvas.VISIBLE) { this.setOverflow(isc.Canvas.HIDDEN); } // suppress adjustOverflow during the animation if we have scrollbars if (this.overflow == isc.Canvas.AUTO || this.overflow == isc.Canvas.SCROLL) { this._suppressAdjustOverflow = true; } // additional param indicates that this is an animated resize this.resizeTo((vertical ? drawnWidth : 1), (vertical ? 1 : drawnHeight), true); if (slideIn) this.scrollTo((vertical ? null : scrollStart + (drawnWidth-1)), (vertical ? scrollStart + (drawnHeight-1) : null)); if (this.showEdges && this._edgedCanvas) { // Explicitly size the edgeCanvas' table (rather than sizing at 100%), so that // as the edged canvas resizes, the edge clips rather than growing/shrinking if (vertical) this._assignSize(this._edgedCanvas.getHandle().firstChild.style, "height", drawnHeight); else this._assignSize(this._edgedCanvas.getHandle().firstChild.style, "width", drawnWidth); this._edgedCanvas.setOverflow(isc.Canvas.HIDDEN); // If we're sliding in, align the handle with the top of the edged canvas to // start with, so it will grow down from the top. if (slideIn) { if (vertical) { var startEdgeSize = this._edgedCanvas._topMargin; this._assignSize(this.getStyleHandle(), "marginTop", (this.getTopMargin() - startEdgeSize)); } else { var startEdgeSize = this._edgedCanvas._leftMargin; this._assignSize(this.getStyleHandle(), "marginLeft", (this.getLeftMargin() - startEdgeSize)); } } // Don't show the main Canvas right away if we have edges, just show the edges. // Only show the edges, then show the main Canvas when the animation has passed the // edge. this._edgedCanvas.show(); } else { var breadthScrollbar = vertical ? (this.hscrollOn ? this.hscrollbar : null) : (this.vscrollOn ? this.vscrollbar : null), lengthScrollbar = vertical ? (this.vscrollOn ? this.vscrollbar : null) : (this.hscrollOn ? this.hscrollbar : null); // If we're sliding in, and we have an h-scrollbar, show it and allow it to grow // before showing this canvas if (breadthScrollbar && info._slideIn) { breadthScrollbar.show(); if (lengthScrollbar) lengthScrollbar.show(); } else { this.show(); } } return this._startAnimation(this._$show, info, duration, acceleration); }, // Actually fire the show animation // Grows the widget (according to the current ratio), and if slideIn is true keeps scrolled // so the content appears to slide in with the bottom of the widget. fireAnimationShow : function (ratio, ID, earlyFinish) { var info = this.$showAnimationInfo, vertical = info._vertical; if (ratio < 1) { var drawnSize = (vertical ? info._drawnHeight : info._drawnWidth), size = this._getRatioTargetValue(1, drawnSize, ratio), delta = drawnSize - size, adjustForEdge = (this.showEdges && this._edgedCanvas), // Note if we're wiping into view we show the top edge, then the bottom edge // if we're sliding into view it's the other way around because of scrolling startEdgeSize, endEdgeSize; if (adjustForEdge) { // Note: we can't just check this.edgeSize, since we support asymmetric edges // and by default the value is just picked up from the EdgedCanvas class. startEdgeSize = (info._slideIn ? (vertical ? this._edgedCanvas._bottomMargin : this._edgedCanvas._rightMargin) : (vertical ? this._edgedCanvas._topMargin : this._edgedCanvas._leftMargin)), endEdgeSize = (info._slideIn ? (vertical ? this._edgedCanvas._topMargin : this._edgedCanvas._leftMargin) : (vertical ? this._edgedCanvas._bottomMargin : this._edgedCanvas._rightMargin)); this._edgedCanvas.resizeTo((vertical ? null : size), (vertical ? size: null), true); if (info._slideIn) { if (vertical) this._edgedCanvas.scrollToBottom(); else this._edgedCanvas.scrollToRight(); } // Just bail if we haven't started to expose the actual handle yet. if (size < startEdgeSize) return; // We don't need to resize the handle once it's completely exposed (at this // point we're just revealing the final edge) if (delta <= endEdgeSize) { // If sliding in, align the top of the handle with the bottom of the // top edge, and ensure we're now scrolled to our final scroll position // (avoids a jump when we actually reach ratio 1). if (info._slideIn) { var marginProp = (vertical ? "marginTop" : "marginLeft"), marginSize = (vertical ? this.getTopMargin() - delta : this.getLeftMargin() - delta); this._assignSize(this.getStyleHandle(), marginProp, marginSize); this.scrollTo((vertical ? null : info._scrollStart), (vertical ? info._scrollTop : null), null, true); } return; } // If we got here, we know the handle should be >= 1px tall, so needs to be // visible if (!this.isVisible()) { this._showingAsAnimation = true; this.show(); delete this._showingAsAnimation; } } var lengthScrollOn = vertical ? this.vscrollOn : this.hscrollOn, breadthScrollOn = vertical ? this.hscrollOn : this.vscrollOn; if (lengthScrollOn) { var lengthScrollbar; if (vertical) { lengthScrollbar = this.vscrollbar; lengthScrollbar.resizeTo(null, size); } else { lengthScrollbar = this.hscrollbar; var sbsize = size; if (this.vscrollOn) { if (info._slideIn) { sbsize -= this.scrollbarSize; } else { sbsize = Math.min(size, drawnSize-this.scrollbarSize); } } if (sbsize > 0) { lengthScrollbar.resizeTo(sbsize, null); } } if (info._slideIn) { if (vertical) lengthScrollbar.scrollToBottom(); else lengthScrollbar.scrollToRight(); } // thumb if (lengthScrollbar.thumb) { var thumb = lengthScrollbar.thumb; // On a "slideIn" we need to grow the thumb then shift it in from the top if (info._slideIn) { var thumbStart = info._scrollThumbStart - delta, thumbEnd = thumbStart + Math.min(size, info._scrollThumbLength), start = vertical ? this.getTop() : this.getLeft(); if (thumbEnd <= start) { // thumb should already be hidden - don't show it } else { // shorten the thumb if necessary thumbStart = Math.max(start, thumbStart); var thumbLength = Math.min(thumbEnd-thumbStart, size); thumb.resizeTo(vertical ? null : thumbLength, vertical ? thumbLength : null); if (vertical) thumb.scrollToBottom() else thumb.scrollToRight(); thumb.moveTo(vertical ? null : thumbStart, vertical ? thumbStart: null); if (!thumb.isVisible()) thumb.show(); } // on a wipe animation, we simply show, then resize the thumb from the // top down } else { var thumbStart = info._scrollThumbStart, thumbEnd = Math.min((thumbStart + info._scrollThumbLength), (vertical ? this.getTop() + size : this.getLeft() + size)); var end = (vertical ? this.getTop() : this.getLeft()) + size if (end <= thumbStart) { // don't show the thumb yet unless its in view } else { if (vertical) thumb.setHeight(thumbEnd -thumbStart); else thumb.setWidth(thumbEnd-thumbStart); if (!thumb.isVisible()) thumb.show(); } } } } var adjustForScrollbar; if (breadthScrollOn) { var breadthScrollbar = vertical ? this.hscrollbar : this.vscrollbar; adjustForScrollbar = true; if (info._slideIn) { var sbStart = vertical ? (this.getTop() + Math.max(0, (size - this.scrollbarSize))) : (this.getLeft() + Math.max(0, (size - this.scrollbarSize))) breadthScrollbar.moveTo(vertical ? null : sbStart, vertical ? sbStart : null); var sbSize = Math.min(size, this.scrollbarSize); breadthScrollbar.resizeTo(vertical ? null : sbSize, vertical ? sbSize : null); if (vertical) { breadthScrollbar.scrollToBottom(); if (breadthScrollbar.thumb) breadthScrollbar.thumb.scrollToBottom(); } else { breadthScrollbar.scrollToRight(); if (breadthScrollbar.thumb) breadthScrollbar.thumb.scrollToRight(); } if (size > this.scrollbarSize && !this.isVisible()) { this._showingAsAnimation = true; this.show(); delete this._showingAsAnimation; } } else { if (delta <= this.scrollbarSize) { if (!breadthScrollbar.isVisible()) breadthScrollbar.show(); breadthScrollbar.resizeTo(vertical ? null : this.scrollbarSize-delta, vertical ? this.scrollbarSize-delta : null); } // Otherwise we know the scrollbar isn't showing - nothing to do here } } // Actually resize the handle. // If we're showing edges, modify the height passed to resizeTo so we don't account // for the bottom edge which is currently clipped. var handleSize = size; if (adjustForEdge) handleSize += endEdgeSize; // ditto with the "breadth" axis scrollbar if (adjustForScrollbar) handleSize += this.scrollbarSize; // Note additional param // - to avoid firing layoutChildren() on every step. // - notify that this is not an external 'resize' call this.resizeTo((vertical ? null : handleSize), (vertical ? handleSize : null), true); if (info._slideIn) { this.scrollTo((vertical ? null : info._scrollStart + delta), (vertical ? info._scrollStart + delta : null), null, true); } // Ratio == 1 } el
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -