Giter VIP home page Giter VIP logo

picker's People

Contributors

mabelyong avatar ustbhuangyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picker's Issues

显示所有二级项目?

比如一个地区选择,应该是先选定是北京还是上海,然后再选择是哪个区,现在把所有二级项目都显示出来了,不合理啊

android手机的webview不支持吗?

在安卓手机webview上,选择‘’项目‘’后点击‘’确定’’按钮 不会触发 picker.select 或者 picker.change 或者 picker.valuechange方法

联动小问题

城市联动选择的时候,在省选择停止的一瞬间,点击确定按钮,这个时候接获取到的第2,3列会不正确。偶然发现的。不过滑动效果确实挺好的。

小小的提个优化建议

css代码我做了优化,添加了从底部弹出的动画效果(源代码有重复无用的):


//UIPickerView 筛选器组件scss源码
@function h($height,$vh:rem) {
  @return $height/20 +$vh; //常数20是根据当前引入的normalize.css 里的 font: 20px / 1.5
}

.picker {
  display: none;
  position: fixed;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  overflow: hidden;
  text-align: center;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  .picker-mask {
    position: absolute;
    z-index: 500;
    width: 100%;
    height: 100%;
    transition: all .5s;
    -webkit-transition: all .5s;
    background: transparent;
    opacity: 0;
    &.show {
      background: rgba(0, 0, 0, 0.6);
      opacity: 1;
    }
  }
  .picker-panel {
    position: absolute;
    z-index: 600;
    bottom: -100%;
    width: 100%;
    background: #fff;
    transition: all .6s;
    -webkit-transition: all 0.6s;
    &.show {
      bottom:0;
      transform: translateY(0);
      -webkit-transform: translateY(0);
    }
    .picker-choose {
      position: relative;
      height: h(45);
      color: #878787;
      font-size: h(14);
      background-color: #f8f8f8;
      &::after {
        position: absolute;
        content: '';
        width: 100%;
        height: 1px;
        left: 0;
        bottom: 0;
        background-color: #ccc;
        transform: scaleY(.5);
        transform-origin: bottom left;
      }
      .picker-title {
        line-height: h(50);
        font-size: h(19);
        text-align: center;
        color: #333;
        display: none;
      }
      .cancel {
        position: absolute;
        padding: h(10);
        font-size: h(17);
      }
      .confirm {
        position: absolute;
        padding: h(10);
        font-size: h(17);
        right: 0;
        color: #2D72F1;
      }
      .cancel {
        left: 0;
        color: #2D72F1;
      }
    }
    .picker-content {
      position: relative;
      .mask-bottom {
        position: absolute;
        z-index: 10;
        width: 100%;
        height: h(68);
        pointer-events: none;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
      }
      .mask-top {
        position: absolute;
        z-index: 10;
        width: 100%;
        height: h(68);
        pointer-events: none;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        top: 0;
        background: -webkit-gradient(linear, left bottom, left top, from(hsla(0, 0%, 100%, 0.4)), to(hsla(0, 0%, 100%, 0.8)));
        background: -o-linear-gradient(bottom, hsla(0, 0%, 100%, 0.4), hsla(0, 0%, 100%, 0.8));
        &:after {
          content: " ";
          display: block;
          position: absolute;
          left: 0;
          bottom: 0;
          width: 100%;
          -webkit-transform: scaleY(0.5);
          transform: scaleY(0.5);
          border-top: 1px solid #ccc;
          -webkit-transform-origin: left bottom;
          transform-origin: left bottom;
        }
      }
      .mask-bottom {
        bottom: 0;
        background: -webkit-gradient(linear, left top, left bottom, from(hsla(0, 0%, 100%, 0.4)), to(hsla(0, 0%, 100%, 0.8)));
        background: -o-linear-gradient(top, hsla(0, 0%, 100%, 0.4), hsla(0, 0%, 100%, 0.8));
        &:before {
          content: " ";
          display: block;
          position: absolute;
          left: 0;
          width: 100%;
          top: 0;
          border-top: 1px solid #ccc;
          -webkit-transform: scaleY(0.5);
          transform: scaleY(0.5);
        }
      }
    }
    .wheel-wrapper {
      display: -ms-flexbox;
      display: -webkit-box;
      display: -webkit-flex;
      display: flex;
      padding: 0 h(10);
      .wheel {
        -ms-flex: 1 1 1 e-9px;
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        flex: 1;
        -webkit-flex-basis: 1 e-9px;
        flex-basis: 1 e-9px;
        width: 1%;
        height: h(172);
        overflow: hidden;
        font-size: h(21);
        .wheel-scroll {
          margin-top: h(68);
          line-height: h(36);
          .wheel-item {
            height: h(36);
            overflow: hidden;
            white-space: nowrap;
            color: #333;
          }
        }
      }
    }
  }
  .picker-footer {
    height: h(20);
  }
}

希望加入三元运算

例:   <input type="text" id="job" readonly>)

//        JS 获取方法
//        var job = [{text: '国家公务员', value: 1}, {text: '编辑策划', value: 2}, {text: '专业技术', value: 3}, {text: '公司职员', value: 4}, {text: '企业管理', value: 5}, {text: '服务人员', value: 6}, {text: '现役军人', value: 7}, {text: '在读学生', value: 8}, {text: '自由职业', value: 9}, {text: '其他', value: 10}];
//
//        var picker0El = document.getElementById('job');
//        var tag =picker0El.tagName.toLowerCase();
//        var picker0 = new Picker({data: [job]});
//        picker0.on('picker.select', function (selectedVal, selectedIndex) {
//              //判断当前ID元素的tagName,写入对应数据;
//              tag=='input'? picker0El.setAttribute("value",job[selectedIndex[0]].text): nameEl.innerText = job[selectedIndex[0]].text;
//        });
//
//        picker0El.addEventListener('click', function () {
//              picker0.show();//显示UIPickerView 筛选器组件
//        });

//      JQ 获取方法
        $('#job').on('click', function () {
            const $this = $(this);
            const $tag=$this.prop('tagName').toLowerCase();
            const job = [{text: '国家公务员', value: 1}, {text: '编辑策划', value: 2}, {text: '专业技术', value: 3}, {text: '公司职员', value: 4}, {text: '企业管理', value: 5}, {text: '服务人员', value: 6}, {text: '现役军人', value: 7}, {text: '在读学生', value: 8}, {text: '自由职业', value: 9}, {text: '其他', value: 10}];
            const picker0 = new Picker({data: [job]});
            picker0.show();
            picker0.on('picker.select', function (selectedVal, selectedIndex) {
                $tag=='input'?$this.val(job[selectedIndex[0]].text): $this.text(job[selectedIndex[0]].text);
            });
        })


强烈建议:城市联动选择器的调用方法: PickerCity(id);
就是把亲的 "..\picker-master\docs\city\index.js" 用一个函数封装起来,然后调用。
----------------------------------------------------------------
        function PickerCity(id) {
            var idName = id == undefined ? 'city' : id;
            var nameEl = document.getElementById(idName);
            var tag =nameEl.tagName.toLowerCase();
        ……
         picker.on('picker.select', function (selectedVal, selectedIndex) {
             var text1 = first[selectedIndex[0]].text;
             var text2 = second[selectedIndex[1]].text;
             var text3 = third[selectedIndex[2]] ? third[selectedIndex[2]].text : '';
             /*判断当前ID元素的tagName,写入对应数据;*/
             tag=='input'? nameEl.setAttribute("value",text1 + ' ' + text2 + ' ' + text3): nameEl.innerText = text1 + ' ' + text2 + ' ' + text3;
         });
        ……
        
        }
----------------------------------------------------------------

        1. PickerCity() 是调用城市筛选器的函数,默认调用的元素ID为“city”,可以不带ID。
        例: <input type="text" id="city" readonly>
               PickerCity();

        2. 如果默认ID不是“city”,需带参元素ID。
        例: <input type="text" id="currentCity" readonly>
               PickerCity('currentCity');



年月日的选择

强烈建议加入普通的日期选择,这么好的动画效果,没有最常见的日期选择岂不是太可惜了!!强烈建议!!不然还要自己封装年月日的数据往里面填

refill bug

refill的时候会报can not read undefine[0],可能哪里没有初始化,麻烦作者看看,不知道你还在维护这个项目吗?

构建时候报错

ERROR in .//.0.23.1@css-loader!.//.1.6.1@stylus-loader!./src/picker/picker.styl
Module build failed: TypeError: E:\Project\happyvalleyApp-pay\plugins\picker\src\picker\picker.styl:111:1
107| .border-1px
108| &::after, &::before
109| -webkit-transform: scaleY(.5)
110| transform: scaleY(.5)
111|
--------^
112|

Path must be a string. Received undefined

window 10/ node v6.9.1/ npm v3.10.5

BUG 提交

IE 模式下,会提示 picker.min.js 里面的 26行 e: {default:e}; 错误,缺少标识符、字符串或数字。。应该是JSON 最后的符号,最后一个符号不应该加”,“ 引起的,只是不知道在哪个地方。demo 里面也是这样,麻烦处理一下

城市联动选择bug

picker.change事件是监控当滚动停止时触发。
倘若误操作or非正规操作下,当滚动没有停止时确定,城市关联出现问题

wechatimg20

是否还有其他监控事件,当滚动事件开始,第一级改变时第二三级清空,当滚动停止时触发关联。
谢谢

新需求:添加重载的方法

业务场景:

在一些页面当中,可能存在多个需要用到picker组件的地方。如果每次都new一个新的picker,会在DOM当中新插入一个picker。可以只使用一个picker来满足多个需要选择的业务场景

可添加2个方法:

  • changeTitle
  • reConstruct

changeTitle用以改变title的显示,reConstruct区别于refill方法,可以提供3列选项的替换.

怎么是显示所有二级项目

比如一个地区选择,应该是先选定是北京还是上海,然后再选择是哪个区,现在把所有二级项目都显示出来了,不合理啊

2级联动scroll事件绑定的问题

./src/picker/picker.js文件第107行加入滚动的监听

this.wheels[index].on('scroll', () => {
        console.log(3333);
      });

发现并没有被监听,反而是scrolStart这些就可以,这是为什么呢

viewport自动缩放好改吗

信了淘宝的忽悠,viewport自动缩放了,不是大多数那种设置为1.0了..
现在搜索到的picker都是1.0倍的,并且我找到的你的picker是最流畅的(同样流畅度的picker不超过两个)..
好不好改.

警示:插件有致命bug,不要使用

当页面长度超过一屏,页面有滚动条时,当向下滑动滚动条,然后再点击插件选择,插件完全不能上下滑动进行选择,在苹果5,苹果6s下,chrome,safari,uc,安卓的 uc, 手机百度,浏览器测试都有这个问题。提醒大家,此bug不解决,不要使用此插件

refill方法无法数据填充。

直接报Cannot read property '0' of undefined。还有因为用的angular,很难和你另外那个VUE picker插件结合。
代码如下:
ngOnInit(){
//界面初始化
this.picker=new Picker({
data: [[{text:1,value:1}]],
title: "选择阈值",
selectedIndex: [0]
})
}
selectPicker(i){
//点击后的回调
let newData=[[{text:2,value:12}]]
this.picker.refill(newData);
this.picker.show();
console.log(this.picker.data)
}

引用构建时候报错

ERROR in ./~/better-picker/dist/picker.min.js Module build failed: ReferenceError: Unknown plugin "add-module-exports" specified in "/Users/zhoutao/work/statics/node_modules/better-picker/.babelrc" at 0, attempted to resolve relative to "/Users/zhoutao/work/statics/node_modules/better-picker"
wx20170419-102518 2x

这个有时候会出现bug

选完第二级出现第三级,有时候再选第二级的时候 第三级没变动.,不知道大家有没有遇到过

安卓手机点击数据消失

picker在点击一次选中三列数据过后,html能正常显示选中的文本,在点击第二次只滚动一列,然后确定,只有选中的值变化!其余二列都是第一行!在安卓手机是这样!!..... 苹果跟浏览器正常

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.