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

📄 layout.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
            if (member.isDirty()) member.redraw("Layout getting new size");        } else {            // cause undrawn members to draw (drawOffscreen because we haven't positioned them            // yet and don't want them to momentarily appear stacked on top of each other)            if (!member.isDrawn()) member._needsDraw = true;        }    }},// if stackZIndex is "firstOnTop" or "lastOnTop", ensure all managed members have // consistently increasing or decreasing Z-order, except members which should be ignored // (such as selected tabs in a TabBar which must be at the top)._enforceStackZIndex : function () {    if (!this.stackZIndex || this.members.length < 2) return;        // advance to the first non-ignored member    for (var firstStacked=0; firstStacked<this.members.length; firstStacked++)        if (!this._isIgnoringMemberZIndex(this.members[firstStacked])) break;        var thisMember=this.members[firstStacked], thisZ=thisMember.getZIndex();    var lastMember, lastZ;        // compare the Z-order of each stackable member to the last stackable member before    // it. Adjust the Z-order if it does not match the stack ordering.    for (var i = firstStacked+1; i < this.members.length; i++) {        if (this._isIgnoringMemberZIndex(this.members[i])) continue;        lastMember = thisMember;        lastZ = lastMember.getZIndex();        thisMember = this.members[i];        thisZ = thisMember.getZIndex();                if ((thisZ <= lastZ) && this.stackZIndex == "lastOnTop")            thisMember.moveAbove(lastMember);        else if ((thisZ >= lastZ) && this.stackZIndex == "firstOnTop")            thisMember.moveBelow(lastMember);    }},//>Animation When the member is in the middle of an animated move, avoid attempting to move as// part of layout._moveAnimations:["rect", "move"], //<AnimationstackMembers : function (members, layoutInfo, updateSizes) {        if (updateSizes == null) updateSizes = true;        // top/left coordinate of layout: if members are children, placing a member at 0,0    // places it in the top left corner of the Layout, since child coordinates are relative    // to the parent.  Otherwise, if members are peers, the top/left corner is the    // offsetLeft/Top with respect to the Layout's parent    var layoutLeft = (this.membersAreChildren ? 0 : this.getOffsetLeft()),        layoutTop = (this.membersAreChildren ? 0 : this.getOffsetTop()),        // support reversing the order members appear in        reverse = this.reverseOrder,        direction = (reverse ? -1 : 1);        // breadth to use for centering based on specified size, which we'll use as is    // for the clipping/scrolling case, and acts as a minimum for the overflow case.      // Note getInner* takes into account native margin/border    var centerBreadth = (this.vertical ? this.getInnerWidth() : this.getInnerHeight())            - this._getBreadthMargin();    if ((this.vertical && this.canOverflowWidth()) ||         (!this.vertical && this.canOverflowHeight()))    {        // overflow case.  Note we can't just call getScrollWidth() and subtract off synthetic        // margins because members have not been placed yet.        for (var i = 0; i < this.members.length; i++) {            var member = this.members[i];            // ignore hidden members and explicitly ignored members            if (this._shouldIgnoreMember(member)) continue;            var value = this.getMemberBreadth(member);            if (value > centerBreadth) centerBreadth = value;        }    }    if (this.logIsDebugEnabled(this._$layout)) {        this.logDebug("centering wrt visible breadth: " + centerBreadth, this._$layout);    }        var totalLength;    if (reverse) {        if (this.isRTL() && !this.vertical) {                        totalLength = this.getLength();        } else {            totalLength = Math.max(this.getLength(), this._getTotalMemberLength());        }    }    	// start position of the next member on length axis.    // if reversing, start stacking at end coordinate at work backwards.  Note that this    // effectively creates right/bottom alignment by default.     var nextMemberPosition = (this.vertical ?                                 (!reverse ? layoutTop : layoutTop + totalLength) :                                 (!reverse ? layoutLeft : layoutLeft + totalLength)                             );        // if align has been set to non-default,     if (this.align != null &&         ((!reverse && (this.align == isc.Canvas.BOTTOM || this.align == isc.Canvas.RIGHT)) ||         (reverse && (this.align == isc.Canvas.LEFT || this.align == isc.Canvas.TOP))))    {        // leave the space that would have been at the end at the beginning instead.        // if reversed, hence normally right/bottom aligned, and align has been set to        // left/top, subtract off remaining space instead.  NOTE: can't simplify reversal to        // just mean right/bottom align: reverse stacking starts from endpoint and subtracts        // off sizes during stacking.        var totalMemberLength = this._getTotalMemberLength(),            visibleLength = Math.max(this.getLength(), totalMemberLength),            remainingSpace = visibleLength - totalMemberLength;        nextMemberPosition += (direction * remainingSpace);    }    // start position of all members on breadth axis    var defaultOffset = (this.vertical ? layoutLeft + this._leftMargin :                                          layoutTop + this._topMargin),        lastMemberHadResizeBar = false,        lastMemberWasHidden = false,        numHiddenMembers = 0;        	for (var i = 0; i < members.length; i++) {        var member = members[i],            // NOTE: layoutInfo is optional, only used for reporting purposes when stackMembers is            // called as part of a full layoutChildren run            memberInfo = layoutInfo ? layoutInfo[i] : null;        // margin before the member / room for resizeBar        if (i == 0) {            // first element is preceded by the outer margin of the layout as a whole.              // NOTE: the last element is implicitly followed by the outer margin because space            // for it is subtracted before we determine sizes.            var startMargin;            if (this.vertical) startMargin = (reverse ? this._bottomMargin : this._topMargin);            else startMargin = (reverse ? this._rightMargin : this._leftMargin);            nextMemberPosition += (direction * startMargin);        } else {            if (lastMemberHadResizeBar) {                // if the last member showed a resizeBar, leave room for it                nextMemberPosition += (direction * this.resizeBarSize);            } else if (!lastMemberWasHidden) {                // otherwise leave the members margin (note: avoid stacking margins if a member                // is hidden)                nextMemberPosition += (direction * this.membersMargin);            }        }                //>Animation        // Avoid interrupting animations in progress with any kind of move        var animating = member.isAnimating(this._moveAnimations); //<Animation                 // skip hidden members        if (this._shouldIgnoreMember(member)) {                        if (!this.isIgnoringMember(member)                //>Animation                && !animating   //<Animation               ) {                member.moveTo(layoutLeft + this._leftMargin, layoutTop + this._topMargin);            }            // if a hidden member has a resizeBar (it was previously visible) leave the            // resizeBar showing, and place it properly            if (member.showResizeBar) {                var breadth = this.getBreadth() - this._getBreadthMargin();                this.makeResizeBar(member, defaultOffset, nextMemberPosition, breadth);                lastMemberHadResizeBar = true;            } else {                if (member._resizeBar != null) member._resizeBar.hide();                lastMemberHadResizeBar = false;            }            lastMemberWasHidden = true;            numHiddenMembers++;            continue;        } else {            lastMemberWasHidden = false;        }        // handle alignment (default is left/top)        var offset = defaultOffset,            Canvas = isc.Canvas,            layoutAlign = this.getLayoutAlign(member);        // NOTE: the centerBreadth properly subtracts out layoutMargins        if (layoutAlign == Canvas.RIGHT || layoutAlign == Canvas.BOTTOM) {            offset = centerBreadth - this.getMemberBreadth(member)                 + (this.vertical ? this._leftMargin : this._topMargin);        } else if (layoutAlign == Canvas.CENTER) {            offset = Math.floor((centerBreadth - this.getMemberBreadth(member))/2)                     + (this.vertical ? this._leftMargin : this._topMargin);        }        if (this.getMemberOffset != null)            offset = this.getMemberOffset(member, offset, layoutAlign);                var memberLength = this.getMemberLength(member);        //>Animation        if (!animating) {//<Animation         // move the member into position		if (this.vertical) {            if (!reverse) member.moveTo(offset, nextMemberPosition);            else member.moveTo(offset, nextMemberPosition-memberLength);        } else {            if (!reverse) member.moveTo(nextMemberPosition, offset);            else member.moveTo(nextMemberPosition-memberLength, offset);        }                //>Animation        } //<Animation         // next member will be placed after this one        nextMemberPosition += (direction * memberLength);        // leave extra space on a member-by-member basis        nextMemberPosition += (direction * this.getMemberGap(member));		        // show a resize bar for members that request it        if (member.showResizeBar) {            var breadth = this.getBreadth() - this._getBreadthMargin();            this.makeResizeBar(member, defaultOffset, nextMemberPosition, breadth);        } else {            // ensure we hide the resizebar for any hidden members.            if (member._resizeBar != null) member._resizeBar.hide();        }        lastMemberHadResizeBar = member.showResizeBar;        // update memberSizes.  NOTE: this is only necessary when we have turned off the sizing        // policy are doing stackMembers() only        if (updateSizes) this.memberSizes[i - numHiddenMembers] = memberLength;        // record length for reporting if being called as part of layoutChildren        if (layoutInfo) memberInfo._visibleLength = memberLength;	}    // trim memberSizes to the currently visible members.  NOTE: this is only necessary when we have    // turned off the sizing policy are doing stackMembers() only    if (updateSizes) this.memberSizes.length = (i - numHiddenMembers);        // Ensure that the reported scroll-size matches the scrollable area of this layout.    if (this.overflow != isc.Canvas.VISIBLE) this._enforceScrollSize();    this._enforceStackZIndex();},// determine the breadth axis alignment per member.getLayoutAlign : function (member) {    if (member.layoutAlign != null) return member.layoutAlign;    if (this.defaultLayoutAlign != null) return this.defaultLayoutAlign;    return this.vertical ? isc.Canvas.LEFT : isc.Canvas.TOP;},_enforceScrollSize : function () {        var breadthLayoutMargin,        lengthLayoutMargin,        hasMargin = false, spacerForcesOverflow = false,                lastMember,         member,         scrollBottom, scrollRight, vertical = this.vertical;    // convert null margins to zero so we don't need to worry about doing math with them    if (vertical) {        lengthLayoutMargin = this._bottomMargin || 0;        breadthLayoutMargin = this._rightMargin || 0;    } else {        lengthLayoutMargin = this._rightMargin || 0;        breadthLayoutMargin = this._bottomMargin || 0;    }        if (lengthLayoutMargin > 0 || breadthLayoutMargin > 0) hasMargin = true;         var innerWidth = this.getInnerWidth(),        innerHeight = this.getInnerHeight();    // If we have layout margins that cause scrolling, we need to find the bottom (or right)     // of the last member, and the right (or bottom) of the broadest member to enforce scroll     // size.    // In this case just iterate through every member to find our broadest member.    if (hasMargin) {        for (var i = this.members.length-1 ; i >= 0; i--) {            member = this.members[i];            if (!member.isVisible()) continue;                        if (vertical) {                if (lastMember == null) {                    lastMember = member;                                scrollBottom = member.getTop() + member.getVisibleHeight();                }                    var right = member.getLeft() + member.getVisibleWidth();                if (scrollRight == null || scrollRight < right) scrollRight = right;                                } else {                if (lastMember == null) {                    lastMember = member;                    scrollRight = member.getLeft() + member.getVisibleWidth();                }                                var bottom = member.getTop() + member.getVisibleHeight();                if (scrollBottom == null || scrollBottom < bottom) scrollBottom = bottom;            }        }                // If we had no visible members we still need a valid scrollBottom/scrollLeft         // to enforce, or we'll end up trying to math on null values         if (scrollBottom == null) scrollBottom = 0;        if (scrollRight == null) scrollRight = 0;    // if we have no layout margins, we will only need to enforce scrollSize if our last member    // is a layout spacer and/or our broadest member is a layout spacer (and is wider than    // this.innerWidth    // In this case, for efficiency, iterate through our members array checking for a layout     // spacer at the end, or one that effects the broadness of the content.    // Then, iff we found a layoutSpacer that effects the broadness of the content, iterate    // through all the other members

⌨️ 快捷键说明

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