DART / Flutter中的isInViewport

时间:2019-07-12 11:42:40

标签: flutter dart

一旦用户在屏幕上看到某个元素,我想说些什么,类似于WhatsApp蓝色箭头或Messenger阅读箭头。

我找到了this javascript帮助器,DART / Flutter中是否有类似的东西?

var isInViewport = function (elem) {
    var distance = elem.getBoundingClientRect();
    return (
        distance.top >= 0 &&
        distance.left >= 0 &&
        distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
        distance.right <= (window.innerWidth || document.documentElement.clientWidth)
    );
};

var findMe = document.querySelector('#find-me');

window.addEventListener('scroll', function (event) {
    if (isInViewport(findMe)) {
        console.log('In viewport!');
    } else {
    console.log('Nope...');
  }
}, false);

0 个答案:

没有答案