當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript view.View類代碼示例

本文整理匯總了TypeScript中ui/core/view.View的典型用法代碼示例。如果您正苦於以下問題:TypeScript View類的具體用法?TypeScript View怎麽用?TypeScript View使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了View類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: onMeasure

    public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
        AbsoluteLayout.adjustChildrenLayoutParams(this, widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        let measureWidth = 0;
        let measureHeight = 0;
        
        let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
        let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
        
        let height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
        let heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
        
        let childMeasureSpec = utils.layout.makeMeasureSpec(0, utils.layout.UNSPECIFIED);
        let density = utils.layout.getDisplayDensity();

        this.eachLayoutChild((child, last) => {
            let childSize = View.measureChild(this, child, childMeasureSpec, childMeasureSpec);
            measureWidth = Math.max(measureWidth, AbsoluteLayout.getLeft(child) * density + childSize.measuredWidth);
            measureHeight = Math.max(measureHeight, AbsoluteLayout.getTop(child) * density + childSize.measuredHeight);
        });

        measureWidth += (this.paddingLeft + this.paddingRight) * density;
        measureHeight += (this.paddingTop + this.paddingBottom) * density;

        measureWidth = Math.max(measureWidth, this.minWidth * density);
        measureHeight = Math.max(measureHeight, this.minHeight * density);

        let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
        let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);

        this.setMeasuredDimension(widthAndState, heightAndState);
    }
開發者ID:329379172,項目名稱:NativeScript,代碼行數:33,代碼來源:absolute-layout.ios.ts

示例2: onMeasure

 onMeasure(widthMeasureSpec, heightMeasureSpec) {
   let utils = require("utils/utils"),
     width = utils.layout.getMeasureSpecSize(widthMeasureSpec),
     widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec),
     height = utils.layout.getMeasureSpecSize(heightMeasureSpec),
     heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec),
     nativeWidth = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.width : 0) : 0,
     nativeHeight = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.height : 0) : 0,
     measureWidth = Math.max(nativeWidth, this.minWidth as number),
     measureHeight = Math.max(nativeHeight, this.minHeight as number),
     finiteWidth = widthMode !== utils.layout.UNSPECIFIED,
     finiteHeight = heightMode !== utils.layout.UNSPECIFIED;
   if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
     let scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.stretch),
       resultW = Math.floor(nativeWidth * scale.width),
       resultH = Math.floor(nativeHeight * scale.height);
     measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
     measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
     let trace = require("trace");
     trace.write("Image stretch: " + this.stretch +
       ", nativeWidth: " + nativeWidth +
       ", nativeHeight: " + nativeHeight, trace.categories.Layout);
   }
   let view = require("ui/core/view");
   let widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
   let heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
   this.setMeasuredDimension(widthAndState, heightAndState);
 }
開發者ID:VideoSpike,項目名稱:nativescript-web-image-cache,代碼行數:28,代碼來源:web-image-cache.ios.ts

示例3: switch

        this.eachLayoutChild((child, last) => {
            let lp: CommonLayoutParams = child.style._getValue(nativeLayoutParamsProperty);

            let childWidth = child.getMeasuredWidth() + (lp.leftMargin + lp.rightMargin) * density;
            let childHeight = child.getMeasuredHeight() + (lp.topMargin + lp.bottomMargin) * density;
            
            if (last && this.stretchLastChild) {
                // Last child with stretch - give it all the space and return;
                View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight);
                return;
            }
            
            let dock = DockLayout.getDock(child);
            switch (dock) {
                case Dock.top:
                    childLeft = x;
                    childTop = y;
                    childWidth = remainingWidth;
                    y += childHeight;
                    remainingHeight = Math.max(0, remainingHeight - childHeight);
                    break;

                case Dock.bottom:
                    childLeft = x;
                    childTop = y + remainingHeight - childHeight;
                    childWidth = remainingWidth;
                    remainingHeight = Math.max(0, remainingHeight - childHeight);
                    break;

                case Dock.right:
                    childLeft = x + remainingWidth - childWidth;
                    childTop = y;
                    childHeight = remainingHeight;
                    remainingWidth = Math.max(0, remainingWidth - childWidth);
                    break;

                case Dock.left:
                default:
                    childLeft = x;
                    childTop = y;
                    childHeight = remainingHeight;
                    x += childWidth;
                    remainingWidth = Math.max(0, remainingWidth - childWidth);
                    break;
            }

            View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
        });
開發者ID:329379172,項目名稱:NativeScript,代碼行數:48,代碼來源:dock-layout.ios.ts

示例4:

        this.eachLayoutChild((child, last) => {
            let lp: CommonLayoutParams = child.style._getValue(nativeLayoutParamsProperty);

            let childWidth = child.getMeasuredWidth();
            let childHeight = child.getMeasuredHeight();

            let childLeft = (this.paddingLeft + AbsoluteLayout.getLeft(child)) * density;
            let childTop = (this.paddingTop + AbsoluteLayout.getTop(child)) * density;
            let childRight = childLeft + childWidth + (lp.leftMargin + lp.rightMargin) * density;
            let childBottom = childTop + childHeight + (lp.topMargin + lp.bottomMargin) * density;

            View.layoutChild(this, child, childLeft, childTop, childRight, childBottom);
        });
開發者ID:329379172,項目名稱:NativeScript,代碼行數:13,代碼來源:absolute-layout.ios.ts

示例5: animate

 // >> chaining-animations-code
 animate(target: View) {
     let duration = 300;
     target.animate({ opacity: 0, duration: duration })
         .then(() => target.animate({ opacity: 1, duration: duration }))
         .then(() => target.animate({ translate: { x: 200, y: 200 }, duration: duration }))
         .then(() => target.animate({ translate: { x: 0, y: 0 }, duration: duration }))
         .then(() => target.animate({ scale: { x: 5, y: 5 }, duration: duration }))
         .then(() => target.animate({ scale: { x: 1, y: 1 }, duration: duration }))
         .then(() => target.animate({ rotate: 180, duration: duration }))
         .then(() => target.animate({ rotate: 0, duration: duration }))
         .then(() => {
             console.log("Animation finished");
         })
         .catch((e) => {
             console.log(e.message);
         });
 }
開發者ID:KingAndroid,項目名稱:nativescript-sdk-examples-ng,代碼行數:18,代碼來源:chaining-animations.component.ts

示例6: popAnimate

export function popAnimate(view: View) {
    
    var defPopUp: AnimationDefinition = {
        duration: duration,
        curve: AnimationCurve.easeIn,
        scale: { x: scaleFactor, y: scaleFactor }
    };
    
    var defPopDown: AnimationDefinition = {
        duration: duration,
        curve: AnimationCurve.easeOut,
        scale: { x: 1.0, y: 1.0 }
    };

    return view.animate(defPopUp)
           .then(()=>{
               view.animate(defPopDown);
            });
}
開發者ID:ArronNandoTech,項目名稱:NativeScript-Demo,代碼行數:19,代碼來源:animation-helper.ts

示例7: onDoubleTap

export function onDoubleTap(args: GestureEventData) {
    console.log("DOUBLETAP");

    item.animate({
        translate: { x: 0, y: 0 },
        scale: { x: 1, y: 1 },
        curve: "easeOut",
        duration: 300
    }).then(function () {
        updateStatus();
    });

    updateStatus();
}
開發者ID:toddanglin,項目名稱:native-script-pan-scale-demo,代碼行數:14,代碼來源:main-page.ts

示例8:

 .then(() => target.animate({ rotate: 0, duration: duration }))
開發者ID:KingAndroid,項目名稱:nativescript-sdk-examples-ng,代碼行數:1,代碼來源:chaining-animations.component.ts


注:本文中的ui/core/view.View類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。