ArthurClemens / mithril-slider

Content slider for Mithril for mobile and desktop
30 stars 5 forks source link

responsive slider #1

Closed cmnstmntmn closed 7 years ago

cmnstmntmn commented 8 years ago

i figured to make it responssive by changing width values from px to vw

const posPx = (i - 1) * 100 + 'vw';

and few other style declarations, got modified this way.

the problem is with .content wraper's width that doesn't get updated (based on it's content)

anyway i managed to fix this, the following way:

i call m.redraw() in the view, at window resize event

window.addEventListener("resize", function(e) {
   m.redraw() //notify view
})

is this ok, or there's a more elegant way to do it ?

ArthurClemens commented 8 years ago

Good suggestion. I will look into it in a couple of days.

ArthurClemens commented 8 years ago

An alternative approach is to use calc()

futurist commented 8 years ago

You can use this lib https://github.com/cssobj/cssobj instead of calc() or vw for better combatibility.

Or, instead of j2c.