Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Full Screen Mobile Menu - links don't work when drag activated

  1. #1
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default Full Screen Mobile Menu - links don't work when drag activated

    1) Script Title: Full Screen Mobile Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...screenmenu.htm

    3) Describe problem: The problem is first described here: http://www.dynamicdrive.com/forums/s...780#post310780 and confirmed here: http://fofwebdesign.co.uk/template/_...ullscreenmenu/

    When more links are added to the menu list, to the point where the menu needs to be scrolled/dragged, ALL links become inactive via a single tap, although the "tap and hold to open in a new window" behaviour is present.

    I've only been able to test a little bit on iPhone 5S. Unfortunately I am snowed in and currently unable to get to a desktop computer to compare.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  2. #2
    Join Date
    Aug 2009
    Location
    utf-8
    Posts
    205
    Thanks
    4
    Thanked 7 Times in 7 Posts

    Default

    Can confirm. I have a touchscreen laptop (HP ENVY 15 X360) where I can click the links using my mouse but when I try to use the touchscreen and tap the links nothing happens. I used Chrome 40 to test.
    An inline div is a freak of the web and should be beaten until it becomes a span

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ok, please try the below modified .js file- does it fix all issues for you?
    Attached Files Attached Files
    DD Admin

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I'm really sorry ddadmin but I'm still snowed in and stuck on iPhone, so I can't download the file. Would it be possible to post the contents into code tags so that I can copy and paste direct from a forum post?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Certainly, here it is:

    Code:
    /*Full screen mobile menu By Dynamic Drive
    * Created: Dec 14th', 2014 by DynamicDrive.com. This notice must stay intact for usage 
    * Author: Dynamic Drive at http://www.dynamicdrive.com/
    * Visit http://www.dynamicdrive.com/ for full source code
    */
    
    (function(w, $){
    
    	var defaults = {
    		animatediconclass: 'animateddrawer' // class of designated main toggle menu icon on the page (will receive ".open" class while menu is open
    	}
    
    	w.fullscreenmenu = function(options){	
    		var s = $.extend({}, defaults, options)
    		
    		var $body = $(document.body)
    		var $menu = null
    		var $navcontent = null
    		var $toggler = null
    		var state = 'closed'
    		var mousemoveevtstr = 'mousemove.dragstart' + s.menuid + ' touchmove.dragstart' + s.menuid
    		var mouseupevtstr= 'mouseup.dragend' + s.menuid + ' touchend.dragend' + s.menuid
    		var dragdist
    
    		if (s.source.charAt(0) == '#'){ // inline menu (id)?
    			init( $(s.source) )
    		}
    		else{ // ajax content
    			loadfile(s.source, init)
    		}
    
    		function loadfile(url, callback){
    			$.ajax({
    				url: url,
    				dataType: 'html',
    				error:function(ajaxrequest){
    					alert('Error fetching content.<br />Server Response: '+ajaxrequest.responseText + '\n\n'
    									+ 'In Chrome and IE, page has to be run online in order for Ajax file to be fetched properly'
    							)
    				},
    				success:function(content){
    					var $content = $(content)
    					$content.prependTo(document.body)
    					callback( $content )
    				}
    			})
    		}
    
    		this.togglemenu = function(action){
    			if ($navcontent === null)
    				return
    			if (action == 'open' || (typeof action == 'undefined' && state == 'closed')){
    				$body.css({overflow: 'hidden'})
    				$navcontent.css({top:0})
    				$menu.addClass('open')
    				$toggler.addClass('open')
    				state = 'open'
    			}
    			else if (action == 'close' || (typeof action == 'undefined' && state == 'open')){
    				$body.css({overflow: 'auto'})
    				$menu.removeClass('open')
    				$toggler.removeClass('open')
    				state = 'closed'
    			}
    		}
    
    		function init(menuref){
    			$menu = (typeof menuref == 'string')? $('#' + s.menuref) : menuref
    			$menu.prependTo(document.body)
    			$navcontent = $menu.find('.navcontent:eq(0)').css({top:0})
    			$toggler = $('.' + s.animatediconclass)
    
    	  	$menu.on('mousedown touchstart', function(e){ // set up swipe/ mouse drag behavior
    				var menuheight = $menu.height()
    				var navcontentheight = $navcontent.get(0).scrollHeight
    				var heightdiff = navcontentheight - menuheight
    				if (heightdiff <= 0) // if nav content height <= parent manu's height, no need to enable vertical dragging
    					return
    	  		var e = (e.type.indexOf('touch') != -1)? e.originalEvent.changedTouches[0] : e
    				var mousey = e.pageY
    				var contenttop = parseInt( $navcontent.css('top') )
    				var clicktime = new Date().getTime()
    				dragdist = 0
    	  		$menu.on(mousemoveevtstr, function(e){
    	  			var e = (e.type.indexOf('touch') != '-1')? e.originalEvent.changedTouches[0] : e
    	  			dragdist=e.pageY-mousey //distance moved vertically
    					var newtopvalue = contenttop + dragdist
    					newtopvalue = (newtopvalue > 0)? 0 : (newtopvalue < -heightdiff)? -heightdiff : newtopvalue // set upper and lower boundaries for new top value
    					$navcontent.css({top: newtopvalue})
    					if (e.type == "mousemove")
    	  				return false //cancel default drag action
    	  		})
    		  	$menu.on('mouseup touchend', function(e){
    		  		$menu.unbind(mousemoveevtstr)
    					if (e.type == "mouseup")
    						return false
    		  	})
    				if (e.type == "mousedown")
    	  			return false //cancel default drag action
    	  	})
    	
    			$menu.on('click', function(e){
    				if (Math.abs(dragdist) > 0 && e.target.tagName == 'A') // cancel click on link if dragdist is greater than 0
    					return false
    			})
    
    		}
    	}
    
    
    }) (window, jQuery)
    DD Admin

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Yes, thank you - the links now work.

    The scrolling isn't as smooth in iPhone now though and there's a new behaviour where I drag the menu upwards (it moves more slowly than before) and the bottom of the screen pulls ups too - hopefully I can attach an image below to show you...

    http://fofwebdesign.co.uk/template/_...menu/image.jpg

    EDIT - just to describe the "pull up" behaviour a little better; I drag the menu upwards but it feels a little "sticky" or "resistant", taking more upwards swipes to scroll the list upwards and reveal more items. During each swipe up, the bottom of the screen (an empty grey nothingness, rather than the white web page) pulls upwards too and momentarily hides the lower items before retracting back to the bottom of the screen. It is a similar behaviour, with the grey nothingness, that usually indicates the end of a normal web page. Hope that helps.
    Last edited by Beverleyh; 01-30-2015 at 08:14 AM. Reason: "Pull up"" description added
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    What if you comment out the line below:

    Code:
    				//if (e.type == "mousemove")
      				return false //cancel default drag action
    DD Admin

  8. #8
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Bump in case you missed the reply.
    DD Admin

  9. #9
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Yes! Perfect! That's sorted it

    No "pull up" anymore.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #10
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ok I've updated the js file on the download page for this: http://www.dynamicdrive.com/dynamici...screenmenu.htm It looks like something has changed in the latest version of Chrome causing the issue, since I could have sworn I tested the menu in it when the script was first released without issues.
    DD Admin

Similar Threads

  1. Full screen mobile menu
    By andywalmsley in forum Dynamic Drive scripts help
    Replies: 21
    Last Post: 01-30-2015, 11:41 AM
  2. Full screen mobile menu .. help required
    By aamirsheikh in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-10-2015, 09:40 PM
  3. full-screen option
    By auntnini in forum JavaScript
    Replies: 3
    Last Post: 05-15-2014, 02:22 AM
  4. script to detect mobile or smaller screen
    By BillTheBuilder in forum Looking for such a script or service
    Replies: 3
    Last Post: 08-15-2012, 06:30 PM
  5. Full-Screen Pop-Up.
    By Moglizorz in forum HTML
    Replies: 5
    Last Post: 04-22-2007, 01:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •