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

ResizeObserver 监听元素的尺寸变化 #18

Open
justjavac opened this issue Nov 13, 2017 · 2 comments
Open

ResizeObserver 监听元素的尺寸变化 #18

justjavac opened this issue Nov 13, 2017 · 2 comments

Comments

@justjavac
Copy link
Owner

监听元素的尺寸变化

var ro = new ResizeObserver( entries => {
  for (let entry of entries) {
    const cr = entry.contentRect;
    console.log('Element:', entry.target);
    console.log(`Element size: ${cr.width}px x ${cr.height}px`);
    console.log(`Element padding: ${cr.top}px ; ${cr.left}px`);
  }
});

// Observe one or multiple elements
ro.observe(someElement);

参考链接

@shinchanZ
Copy link

怎么移除监听

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants