Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter新增了平滑滚动的参数-’@‘ #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kakachake
Copy link
Contributor

使用该参数可在map指定的参数间平滑过渡,结合css的transition可达到更好的效果,当前仅支持map的value为数字时使用,效果如下:
5ivhb-yt0kq

@kakachake
Copy link
Contributor Author

新增了对颜色的支持,效果如下:
szefc-i53ug (1)

@stevenlei
Copy link
Contributor

@kakachake thank you, I have merged to dev branch and working on the README updates, will merge to main later on.

@RexYao97
Copy link

这个功能有个问题,如果filter和map指定刚好重复的话会返回异常的值
例子

  <div
        class="lift-transition-sticky-content"
        tg-from="0"
        tg-to="100"
        tg-edge="cover"
        tg-name="position"
        tg-filter="0,50,100@"
        tg-map="0:50;50:0;100:0"
      ></div>

50-100的值为0,但是最终渲染的会是50,因为map也指定了0的映射值
源码问题在这

export function parseValues() {
 
 if (filter.values.length > 0 && !filter.values.includes(value)) {
      if (filter.mode === 'smooth') {
        let region = calcKeyFrameRegion(mapping, value);
       
        if (region.length) {
          // 这里获取的范围值是 0
          value = calcKeyFrameValue(mapping, value, region);
        } else {
          return;
        }
      } else {
        if (filter.mode === 'exact') {
          element.lastValue = null;
          el.style.removeProperty(name);
        }
        return;
      }
    }
  // 这里会根据value的值重新获取映射导致异常
   if (typeof mapping[value] !== 'undefined') {
      value = mapping[value];
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants