⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridrenderer.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
        return;    }           var canRedraw = this.readyToRedraw("animating show / hide of rows", false);    if (!canRedraw) {        this._delayedRowAnimationArgs = [show, startRow, endRow, callback, speed,                                          duration, effect, slideIn, fromListGrid];        this._delayedRowAnimation = isc.Timer.setTimeout(                                        {target:this, methodName:"_delayedStartRowAnimation"},                                        0                                    );        return;    }    // redraw, placing an entire subtable with the rows to be animated inside a single row, and    // measure the size of the rows we're going to reveal or hide        var fragmentHeight = this._initializeShowHideRow(show, startRow, endRow, callback, fromListGrid);    // Use animateRowHeight to grow or shrink the height    this.animateRowHeight(this._animatedShowStartRow,                          // NOTE: animate all the way down to zero, so there is no lurch                         // between the final frame of the animation and the subsequent redraw                         (show ? fragmentHeight : 0),                          {target:this, methodName:"_rowShowComplete"},                          speed, duration, effect, slideIn);},// Helper to start delayed row animation_delayedStartRowAnimation : function () {    if (this._delayedRowAnimationArgs == null) {        this.logWarn("Unable to perform delayed row animation - bailing");        return;    }        var argsArr = this._delayedRowAnimationArgs,        show = argsArr[0],        startRow=argsArr[1],        endRow = argsArr[2],         callback = argsArr[3],        speed = argsArr[4],        duration = argsArr[5],        effect = argsArr[6],         slideIn = argsArr[7],        fromListGrid = argsArr[8];            this._delayedRowAnimationArgs = null;    this._delayedRowAnimation = null;    // The additional param indicates that the row animation is delayed        this.startRowAnimation(show, startRow, endRow, callback, speed, duration, effect, slideIn,                            fromListGrid, true);},// helper method to redraw the GR in its state at the beginning of the show/hide row animation// Returns the height of the table fragment to be written into the animation row._initializeShowHideRow : function (show, startRow, endRow, callback, fromListGrid) {    // hang a flag onto this table so we know where the fragment gets written into the normal    // table.    this._animatedShowStartRow = startRow;    this._animatedShowEndRow = endRow;    var fragmentHeight = 0;        // if we're hiding visible rows, we can look at their drawn heights now    if (!show) {        var heights = this._getDrawnRowHeights();        for (var i = startRow; i < endRow; i++) {            fragmentHeight += heights[i];        }            // used when writing out the row containing the fragment             this._animatedShowRowHeight = fragmentHeight;        // This redraw writes out the single animation row with an entire table inside it        this.redraw("initializing animated hide row");            // In this case we're going to show rows that are currently undrawn.    } else {        this._animatedShowRowHeight = 1;        this.redraw("initializing animated show row");        // At this point we have written out the fragment and it's clipped by the containing        // cell / div        var animationCell = this.getTableElement(this._animatedShowStartRow, 0),            clipDiv = this._getCellClipDiv(animationCell);                    if (!clipDiv) {            fragmentHeight = (endRow - startRow) * this.cellHeight;        } else fragmentHeight = clipDiv.scrollHeight;    }        if (this.isDirty()) this.redraw("Initializing row animation requires second redraw");        this._animatedShowCallback = {callback:callback, target:(fromListGrid ? this.parentElement : this)};            return fragmentHeight;},// finishRowAnimation - synchronously short-cut to the end of the current row show/hide // animation, and fire the callback.finishRowAnimation : function () {    // a currently running rowAnimation (show/hide rows) implies a running rowHeightAnimation -     // finishing that will jump to the approprate size and fire the callback to finish the    // show/hide animation    if (this._animatedShowStartRow != null) {        this.finishAnimateRowHeight();            } else {        // In this case we're not running a show/hide row animation - but we may have set up        // a delayed one                if (this._delayedRowAnimation != null) {                    // don't fire the delayed animation            isc.Timer.clearTimeout(this._delayedRowAnimation);            var args = this._delayedRowAnimationArgs,                show = args[0], startRow = args[1], endRow = args[2],                callback = args[3], duration = args[4], fromListGrid = args[5];            delete this._delayedRowAnimationArgs;            delete this._delayedRowAnimation;                        if (!this.readyToRedraw()) {                this.logWarn("Finish row animation called while Grid is not ready to redraw. " +                              "GridRenderer HTML will not be updated when callback fires.", "animation");                var target = fromListGrid ? this.parentElement : this;                if (callback) target.fireCallback(callback);                            } else {                // redraw the GR with the single animation row containing the table fragment                // at the start of the animation height                var fragmentHeight = this._initializeShowHideRow(show, startRow, endRow, callback, fromListGrid);                // set the height to the final height of that row and fire the 'complete' method                // to fire callbacks / clean up vars (rather than ever performing an animation                this.setRowHeight(startRow, (show ? fragmentHeight : 1));                this._rowShowComplete();            }        }     }},// Fired when animated show / hide of rows completes._rowShowComplete : function () {    var callback = this._animatedShowCallback;    delete this._animatedShowCallback;    delete this._animatedShowStartRow;    delete this._animatedShowEndRow;    delete this._animatedShowRowHeight;    // We stored the callback as an object {target:... callback:...}    // This allows us to fire the callback on the ListGrid if that's where the method was    // originally called from    if (callback && callback.callback) callback.target.fireCallback(callback.callback);},//> @method gridRenderer.animateRowHeight()// Will animate a resize of a row to the specified height, firing a callback when the resize// is complete// @param rowNum (number) Row to resize// @param toHeight (number) new height for the row// @param [callback] (callback) Callback to fire when animation completes// @param [speed] (number) Speed for the animation (pixels / second)// @param [duration] (number) duration of the resize in ms// @param [effect] (string) Optionally an acceleration effect can be specified - if not specified//                          default is to do a smooth animation (no acceleration)// @param [slideIn] (boolean) if specified, rows will appear to slide into view rather than //                            being revealed//<// Additional param 'fromListGrid' indicates this was fired from the ListGrid, so we should // fire the callback in that scope_$none:"none",animateRowHeight : function (rowNum, toHeight, callback, speed, duration, effect,                              slideIn, fromListGrid) {    // If we're not drawn, no need to try to animate since this is a visual update only    if (!this.isDrawn()) {        if (callback) {            var target = (fromListGrid ? this.parentElement : this);            target.fireCallback(callback);        }        return;    }        // simultaneous row height animations not currently supported        if (this._rowHeightAnimation != null) {        this.logInfo("early finish of row animation, because new animation started",                     "animation")        this.finishAnimateRowHeight();    }        var fromHeight = this.getRowSize(rowNum);        // If speed (pixels / second) is specified, it takes precedence over duration    if (speed != null) {        var change = (toHeight - fromHeight);        if (change < 0) change = 0 - change;                duration = Math.round((change / speed) * 1000);                // Don't let the animation exceed a maximum        if (duration > this.animateRowsMaxTime) duration = this.animateRowsMaxTime;    }    this._rowAnimationInfo = {        _rowNum:rowNum,        _fromHeight:fromHeight,        _toHeight:toHeight,        _callback:callback,        _slideIn:slideIn,        _fromList:fromListGrid    }    effect = (effect || this._$none);    if (this.logIsInfoEnabled("animation")) {        this.logInfo("starting row animation, duration: " + duration + ", effect: " + effect,                      "animation")    }    this._rowHeightAnimation = this.registerAnimation(                                    {target:this, method:this._fireRowAnimation},                                     duration, effect                               );    // suppress adjustOverflow until the row animation completes. This will avoid unnecessary    // scrollbars from showing up    if (this.overflow == isc.Canvas.AUTO || this.overflow == isc.Canvas.SCROLL)        this._suppressAdjustOverflow = true;},_fireRowAnimation : function (ratio) {    var info = this._rowAnimationInfo,        rowNum = info._rowNum,        rowHeight = this._getRatioTargetValue(info._fromHeight, info._toHeight, ratio);        if (isc.Browser.isSafari && info._fromHeight > info._toHeight)         this._forceRowRefreshForAnimation = true;    // pass in explict "" as className so we don't adjust sizing for the standard row styling    // (which won't be applied to this row during animation)    this.setRowHeight(rowNum, rowHeight, null, isc.emptyString, true, true, true);    if (isc.Browser.isSafari) delete this._forceRowRefreshForAnimation;    if (info._slideIn) {            var clipDiv = this._getCellClipDiv(this.getTableElement(rowNum,0));        if (clipDiv) {            var scrollHeight = clipDiv.scrollHeight,                offsetHeight = clipDiv.offsetHeight;            if (scrollHeight > offsetHeight) clipDiv.scrollTop = scrollHeight - offsetHeight;            else clipDiv.scrollTop = 0;        }    }        // Fire the completion callback in a separate thread - this means if it does a lot of    // processing we shouldn't see a visual pause before the native repaint at the full-size    if (ratio == 1) {        isc.Timer.setTimeout({target:this, methodName:"_rowAnimationComplete"}, 0);    }},// Fired when we're done with a row resize animation_rowAnimationComplete : function () {    // allow standard adjustOverflow to resume    delete this._suppressAdjustOverflow;    this.adjustOverflow("row animation complete");    var info = this._rowAnimationInfo;    delete this._rowHeightAnimation;    delete this._rowAnimationInfo;        if (info && info._callback) {        var target = info._fromList ? this.parentElement : this;        target.fireCallback(info._callback);    }},//> @method gridRenderer.finishAnimatingRowHeight()// Completes any row height animation currently in progress and fires the callback from that// animation.<br>// May be fired automatically to avoid (unsupported) overlapping animations, etc.//<// Leave this as unexposed for nowfinishAnimateRowHeight : function () {    if (!this._rowHeightAnimation) return;        // cancel upcoming animation cycles    this.cancelAnimation(this._rowHeightAnimation);        // Simply firing the "last step" of the rowHeight animation will jump to the appropriate     // height and fire the callback        this._fireRowAnimation(1);},//<Animation// returns the innerHTML for the table// If passed a startRow / endRow, it will return just the HTML for that fragment of the table.getTableHTML : function (colNum, startRow, endRow) {	//>DEBUG	// timing    var t0 = isc.timeStamp();	//<DEBUG    // show empty message    if (this.isEmpty()) {        // clear drawn area        this._firstDrawnRow = this._lastDrawnRow =                 this._firstDrawnCol = this._lastDrawnCol = null;        return this._showEmptyMessage();    }    var fragment = (startRow != null && endRow != null),        rangeStart = startRow != null ? startRow : 0,        rangeEnd = endRow != null ? endRow : this.getTotalRows();    	// Figure out rows and columns to actually draw	// ----------------------------------------------------------------------------------------    var drawRect = this.getDrawArea();     if (!fragment) {        this._firstDrawnRow = drawRect[0];        this._lastDrawnRow = drawRect[1];        //>Animation        // If we're doing an animated show/hide of some rows, we need to write out enough rows        // to fill the viewport when the rows to be animated are sized at zero height (will        // happen either initially or at the end of the draw).        if (this._animatedShowStartRow != null) {                    this._lastDrawnRow += (this._animatedShowEndRow - this._animatedShowStartRow);            var totalRows = this.getTotalRows();            if (this._lastDrawnRow >= totalRows) this._lastDrawnRow = totalRows -1;        }        //<Animation        this._firstDrawnCol = drawRect[2];        this._lastDrawnCol = drawRect[3];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -