/    Sign up×
Community /Pin to ProfileBookmark

Photo swipe script not working

I’m trying to make some pictures on a website “swipable” on mobile devices.

I’m new to javascript and jquery so I could have made any number of mistakes, though I’m not sure where.

(Note: this is similar to a question I posted yesterday, but I have changed quite a few things to make the following more understandable).

I have the following declared in my header (of course these files exist in their respective directories):

[code=html]<link rel=’stylesheet’ href=’http://www.hidden.com/css/jquery.mobile-1.3.2.min.css’>

<script src=’http://www.hidden.com/js/jquery.mobile-1.3.2.min.js’></script>[/code]

This is the way the images are linked right now:

[code=html]<div class=’main_image’>
<a href=’//www.hidden.com/projects/1_west-harbin-station-towers/9.html’ style=’display:block’>
<img src=’http://www.hidden.com/1250_Harbin/hidden_harbin towers9.jpg’ alt=’Interior Rendering from West Harbin Station Towers [hidden]’ style=’max-width:832px; max-height:500px’ title=’West Harbin Station Towers: Interior Rendering. click for next slide (Rendering). ‘>
</a>
</div>[/code]

This is the script I wrote, which goes right after:

[code=html]<script type=’text/javascript’>
jQuery(function(){
jQuery(‘div.main_image’).on(‘swipeleft’, swipeleftHandler);
jQuery(‘div.main_image’).on(‘swiperight’, swiperightHandler);

function swipeleftHandler(event){

JQuery.mobile.changePage(‘//www.spatialpractice.com/projects/1_west-harbin-station-towers/9.html’, {transition: ‘slideleft’, changeHash: false});
}

function swiperightHandler(event){
JQuery.mobile.changePage(‘//www.spatialpractice.com/projects/1_west-harbin-station-towers/7.html’, {transition: ‘slideright’, changeHash: false});
}
});
</script>[/code]

Right now, clicking on the images work, but it does not detect swiping. Any suggestions?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@LesshardtoofindAug 21.2013 — sytax error?

Try changing
<i>
</i>JQuery.mobile.changePage

TO
<i>
</i>jQuery.mobile.changePage


Also I can't see your page but wouldn't it be easier to just have all the pictures on the same page and just change which one is "focused" by swipes left and right, rather than have a new page for each picture?
Copy linkTweet thisAlerts:
@frustuseauthorAug 22.2013 — Thanks for spotting that, though I don't think that was the only issue. I wasn't declaring the jquery library but now that I have, half the site doesn't load and I'm not sure why since none of the code (besides my script) uses jquery. I don't understand how referencing the two jquery libraries can do that.

As for your second comment, this is not my website. I'm just editing it for someone else, so I am not making any of the design decisions.
×

Success!

Help @frustuse spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...