Refactor swipe.js into a library