亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

基于sui 卡尺組件

發布時間:2020-07-28 09:47:42 來源:網絡 閱讀:726 作者:antlove 欄目:開發技術

calliphers.js

define(function(){
    var callipers = {};

    var spaceWidth = 7; // 間隔
    var height = 50; // 默認高度

    var callipersHtml = "<div class='swiper-container'>                 "+
                        "  <div class='swiper-wrapper'>             "+
                        "     <div class='swiper-slide'>           "+
                        "        <div class='callipers-content'></div>"+
                        "     </div>                                   "+
                        "  </div>                                       "+
                        "</div>                                          "+
                        "<canvas></canvas>                               ";

    // 獲取數字長度
    function getNumberLength(number){
        var str = ""+number;
        return str.length;
    }

    function createImage(container,width,height,minValue,maxValue){
        var containerWidth = $(container).width();

        var c=$(container).find("canvas")[0];
        var ctx=c.getContext("2d");

        var multiplyingPower=2;

        c.width=width*multiplyingPower;
        c.height=height*multiplyingPower;


        ctx.strokeStyle="#36384d";
        ctx.lineWidth=1*multiplyingPower;
        // 繪制底部線條
        ctx.beginPath();
        ctx.moveTo(containerWidth/2*multiplyingPower,height*multiplyingPower);
        ctx.lineTo(width*multiplyingPower-containerWidth/2*multiplyingPower,height*multiplyingPower);
        ctx.stroke();

        // 繪制
        for(var i=minValue;i<=maxValue;i++){
            var newIndex = spaceWidth*(i-minValue)+containerWidth/2;
            ctx.moveTo(newIndex*multiplyingPower,50*multiplyingPower);
            if(i==minValue){
                ctx.fillStyle="#959AB9";
                ctx.font="24px Arial ";
                ctx.fillText(i,(newIndex-3)*multiplyingPower,28*multiplyingPower);
                ctx.lineTo(newIndex*multiplyingPower,35*multiplyingPower);
            }else if(i%10==0){// 繪制長線
                ctx.font="24px Arial";
                ctx.fillText(i,(newIndex-6*(getNumberLength(i)-1))*multiplyingPower,28*multiplyingPower);
                ctx.lineTo(newIndex*multiplyingPower,35*multiplyingPower);
            }else{//繪制短線
                ctx.lineTo(newIndex*multiplyingPower,43*multiplyingPower);
            }
            ctx.stroke();
        }
        var p_w_picpathDataUrl = c.toDataURL();
        $(container).find("canvas").remove(); // 刪除canvas
        return p_w_picpathDataUrl;
    }

    function resetSwiperTransition(swiper){
        var translate = swiper.getWrapperTranslate();
        var offset = translate%spaceWidth;
        offset = offset*-1;
        if(offset>spaceWidth/2){
            translate = (parseInt(translate/spaceWidth)-1)*spaceWidth;
        }else{
            translate = (parseInt(translate/spaceWidth))*spaceWidth;
        }
        swiper.setWrapperTranslate(translate);

        var offsetValue = translate/spaceWidth*-1;
        return offsetValue;
    }

    function render(container,settings){
        settings = settings||{};

        var minValue = settings.min||0;
        var maxValue = settings.max||200;
        var progressCallback = settings.progressCallback||function(){};
        var transitionEndCallback = settings.transitionEndCallback||function(){};
        var initValue = settings.initValue||parseInt((maxValue-minValue)/2+minValue);

        var containerWidth= $(container).width();
        var width = spaceWidth*(maxValue-minValue)+containerWidth;

        $(container).html(callipersHtml);
        container.attr("data-min",minValue);
        container.attr("data-max",maxValue);
        var dataURL = createImage(container,width,height,minValue,maxValue);



        $(container).find(".callipers-content").css({
            "background-p_w_picpath":"url("+ dataURL+")",
            "width":width+"px"
        });
        setTimeout(function(){

            $(container).find(".swiper-container").swiper({
                runCallbacksOnInit:false,
                freeModeMomentumRatio:0.2,
                touchRatio:0.5,
                slidesPerView: "auto",
                resistanceRatio: 0,
                freeMode: true,
                onInit:function(swiper){
                    var value = resetSwiperTransition(swiper)+minValue;
                    var offset = (initValue-minValue)*spaceWidth*-1;
                    swiper.setWrapperTranslate(offset);
                    container.attr("data-value",initValue);
                    swiper.updateProgress();
                    container.addClass("initialized");
                },
                onTouchEnd:function(swiper){
                    var value = resetSwiperTransition(swiper)+minValue;
                    transitionEndCallback(value);
                    container.attr("data-value",value);
                },
                onTransitionEnd:function(swiper){
                    var value = resetSwiperTransition(swiper)+minValue;
                    transitionEndCallback(value);
                    container.attr("data-value",value);
                },
                onProgress:function(swiper,progress){
                    var value = parseInt(swiper.getWrapperTranslate()/spaceWidth)*-1+minValue;
                    progressCallback(value);
                    container.attr("data-value",value);
                }
            });
        },100);
        // init swiper

    }

    // 初始化 標尺
    function init(settings){

        var container = settings.container;
        $(container).each(function(){
            render($(this),settings);
        });

    }

    callipers.init = init;


    return callipers;
});

calliphers.css

.callipers{position:relative;opacity:0;}
.callipers.initialized{
    opacity:1;
}
.callipers canvas{display:none;}
.callipers:before{
    content:"";
    position:absolute;
    left:0;
    bottom:0;
    right:0;
    width:1px;
    height:47px;
    background-color:#b540a8;
    margin:auto;
    z-index: 99;
}
.callipers .callipers-content{
    height:50px;
    background:no-repeat center center;
    background-size:contain;
}
.callipers .swiper-container{padding:0;}
.callipers .swiper-container .swiper-wrapper{height:auto;}
.callipers .swiper-container .swiper-slide{width:auto;height:auto;}


test.html

<div class="page-group">
   <div class="page" id="register-base-height">
      <div class="content">
         <div class="callipers "></div>
      </div><!-- content -->
   </div><!-- page -->
</div><!-- page-group -->

test.js

define(["callipers"], function(callipers) {
	$(document).on("pageInit", "#test", function(e, pageId, $page) {
		callipers.init({
			container:$page.find(".callipers"),
			min:20,
			max:220,
			initValue:90,
			progressCallback:function(value){
				console.log("value");
			},
			transitionEndCallback:function(value){
				console.log("value");
			}
		});

	});

	$.init();
});

基于sui 卡尺組件

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

达日县| 贵阳市| 翁源县| 泰宁县| 无为县| 金沙县| 慈利县| 黔江区| 太仓市| 沧源| 涞源县| 阳春市| 灵石县| 万宁市| 山阴县| 西峡县| 江川县| 兴海县| 高邮市| 孟州市| 伊川县| 平江县| 新野县| 清丰县| 雷波县| 子长县| 顺义区| 武城县| 中超| 建宁县| 广昌县| 明水县| 陈巴尔虎旗| 海原县| 阜新| 平武县| 曲松县| 靖边县| 阜阳市| 汉阴县| 延吉市|