Category Archives: Javascript

javascript, js

A tip for event function within a loop, function closure

When I was writing some javascript at work a while ago, I encountered a problem, see below:

When I click the element, it always returned 9, because the event function is not included into the context until it is triggered, therefore, while the click function is triggered, the variable “i” is already 9 (after… Read More »

Javascript Swipe Demo, works both with finger (iOS + Android) and mouse (PC)

View Another Demo In Full Screen Slide One, swipe left please Slide Two, swipe left/right please Slide Three, swipe left/right please Slide Four, swipe right please Mouse: mouse down and swipe left or right, then mouse up Finger: swipe left or right

Disclaimer: The code in the demo is not optimized at all, for… Read More »

Problem: JQuery scrollLeft + Chrome + Hidden Div

When I was writting a modal carousel album display, I was having a strange problem with JQuery scrollLeft in Chrome: I had a div with css set to overflow:hidden and using jquery’s scrollLeft function in order to scroll the thumbnails, everything works, however, if you close the modal (setting the div to display:none), the scrollLeft value change back… Read More »