当前位置: 首页>>代码示例>>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;未经允许,请勿转载。