marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

Update ResizeSensor.js for allow pass parameter to callback function #271

Closed wan-liyang closed 5 years ago

wan-liyang commented 5 years ago

Add params as parameter of new ResizeSensor() and pass params to callback, so that can use following code to pass and get the specific parameter. /pass whatever you want to pass to callback/ new ResizeSensor(jQuery('#id'), callback, params);

function callback(size, params) { }

wan-liyang commented 5 years ago

@marcj , Hi bro, thank you, today i'm fixing one issue of my project use this css-element-queries, and achieve what i want. but sometime need pass prepared object to callback function, and cannot find provided function. so i made this changes.

marcj commented 5 years ago

Why don't you just do

const params = {foo: 'bar'};
function callback(szie, params) {}
new ResizeSensor(jQuery('#id'), (size) => {callback(size, params)});

?

wan-liyang commented 5 years ago

So stupid😞, thank you for correct me.