Using Slider to Change Font Size

20 views
Skip to first unread message

DAZ

unread,
Nov 20, 2011, 7:57:51 AM11/20/11
to RightJS
Hi,

I'm trying to use a slider to change the font size of a heading. I
have this code at the moment:

".rui-slider".onChange (event) ->
$('title').setStyle('font-size', event.getValue())

Unfortunately this doesn't change the size of the font. If I change
event.getValue() to a fixed value it works, so it seems that I just
need how to access the value that the slider is returning. How do I
get this?

thanks,

DAZ

Nikolay Nemshilov

unread,
Nov 20, 2011, 8:05:40 AM11/20/11
to rig...@googlegroups.com
Hi DAZ,

Event is just an event, you need to address the `event.target` to get the slider object.

Then, you also can refer to it via `this` because the callbacks are called in the context of your element, kind of like that

".rui-slider".onChange -> $('title').setStyle('font-size', this.getValue());


--
Cheers,
Nikolay

--
You received this message because you are subscribed to the Google Groups "RightJS" group.
To post to this group, send email to rig...@googlegroups.com.
To unsubscribe from this group, send email to rightjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rightjs?hl=en.


DAZ

unread,
Nov 20, 2011, 8:22:13 AM11/20/11
to RightJS
Thanks Nik,

I also figured out that I needed some units!


".rui-slider".onChange -> $('title').setStyle('font-size',

this.getValue()+"px");

cheers,

DAZ

Nikolay Nemshilov

unread,
Nov 20, 2011, 8:33:24 AM11/20/11
to rig...@googlegroups.com
No worries

--
Thanks,
Nikolay

DAZ

unread,
Dec 1, 2011, 5:29:03 PM12/1/11
to RightJS
Is there any way to get the slider to work on a touch screen?

cheers,

DAZ

Reply all
Reply to author
Forward
0 new messages