- Screen name: xmasmi
xmasmi's Profile
20 Posts
37 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 14-Mar-2014 12:13 AM
- Forum: Using jQuery UI
So below is a diagram that describes what my site looks like.Each list item is horizontally draggable, which works fine, but on multi-touch it is hard to scroll because only the body ( the white area in the diagram ) can trigger scrolling.
Although the list items are horizontally draggable, when you move a finger down on the list-items, it interprets that as a horizontal drag because rarely are those vertical flicks 100% straight.
I am using jQuery UI for the draggable interaction.
How can I make this page vertically scrollable from anywhere on the page like a static page on a multi-touch device is?
- 14-Nov-2013 02:23 PM
- Forum: Using jQuery
Hello,I wrote a jQuery plugin that allows one to pinch in and transform an element on a multi-touch device. On pinch in, it shrinks the element, on pinch out it fires an alert. Later, I'm having it expand the element, but for now, I noticed that while it is working in a page with just itself, it doesn't work in the page I need it to.I've included all the dependencies just like in the stand-alone page and have the code included in jquery,pinch.js applied to the elements I want it to. But on pinch in or out nothing happens.I would greatly appreciate it if someone could help me figure out how to get this working.Here is the stand-alone page where all members of the .polaroid class can be transformed on pinch in / out and it works fine: https://googledrive.com/host/0BwJVaMrY8QdcanhWVTZlODZtUDA/index.htmlAnd here is the page I am trying to get it work on, on the .dataCard class: https://googledrive.com/host/0BwJVaMrY8QdcS2hFTXRZWnVXWjg/KE_home.htmlI've added the dependencies on lines 511 - 513 and initialised it at line 1011.I'm trying to achieve a "parallax background" like in iOS7 where the background moves with mouse movement on hover of the element and device orientation.
I found parallaxify ( https://github.com/hwthorn/parallaxify ) and the demos seem to work perfectly, but when I try to implemnt it, it doesn't work.
I want the backgrounds of #input and #backgroundFix to animate / move when the mouse is over them or when the device is being tilted.
I included the script, here on line 499:https://googledrive.com/host/0BwJVaMrY8QdcWHhEb3k5U3A4WXc/jquery.parallaxify.js
And I initialised it, like so: $('#input, #backgroundFix').parallaxify(); or line 997
However, in the page, the header's background illustration / image is not moving.
Here is the page:https://googledrive.com/host/0BwJVaMrY8QdcWHhEb3k5U3A4WXc/KE_home.html
I would greatly appreciate any and all help in achieving this effect!
- 25-Oct-2013 09:37 PM
- Forum: Using jQuery
If the viewport / window height is 636px or less, I style the container of my site 216px higher, ( `top:-216px` ).This creates extra space below the container and in the body.This also causes the document to not scroll on some mobile devices.What I'm trying to do is make part of my header off canvas, thus making more room for the content to be above-the-fold / in the viewport / window.How can I do this and still have scrolling work?Also how can I get rid of the extra space in the `<body>`? I tried `$('body').css('height', $('body').height() - 216);`, but that makes the body ridiculously small, in height, and the document is still the same size.Here is the URL: http://goo.gl/2yxdHeHere is a JS Fiddle replicating the problem: http://jsfiddle.net/RVvJT/3/Here is the javascript / jQuery that moves the header partially off canvas if at any point, during load or resize, the window is less than 636px in height:- var headerPulledDown = false;
- var headerCanvas = null;
- var vh = $(window).height();
- $(window).on('resize', function(){
- vh=$(window).height();
- if(headerPulledDown === false){
- if(vh <= 636){
- $('#pseudobody').css('top', -216);
- $(document).css('height', $(document).height() - 216);
- $('#pullDownTab').fadeIn();
- headerCanvas = false;
- $('#pseudobody').draggable({
- axis:'y',
- handle:'#pullDownTab',
- drag: function(event, ui){
- if(ui.position.top < -216 || ui.position.top > 0){
- return false;
- }
- if(ui.position.top >= -42){
- $(this).animate({top:'0'});
- $('#pullDownTab').fadeOut();
- headerPulledDown = true;
- headerCanvas = true;
- return false;
- }
- }
- });
- }
- else if(vh > 636){
- $('#pseudobody').css('top', '0');
- $('#pullDownTab').fadeOut();
- headerCanvas = true;
- $('#pseudobody').draggable({
- drag: function(){
- return false;
- }
- });
- }
- }
- });
- if(vh <= 636){
- $('#pseudobody').animate({top:'-216'});
- $(document).css('height', $(document).height() - 216);
- $('#pullDownTab').fadeIn();
- headerCanvas = false;
- $('#pseudobody').draggable({
- axis:'y',
- handle:'#pullDownTab',
- drag: function(event, ui){
- if(ui.position.top < -216 || ui.position.top > 0){
- return false;
- }
- if(ui.position.top >= -42){
- $(this).animate({top:'0'});
- $('#pullDownTab').fadeOut();
- headerPulledDown = true;
- headerCanvas = true;
- return false;
- }
- }
- });
- }
- else if(vh > 636){
- $('#pseudobody').animate({top:'0'});
- $('#pullDownTab').fadeOut();
- $('#pseudobody').draggable({
- drag: function(){
- return false;
- }
- });
- }
- $('#pullDownTab, header, #header, [role="banner"]').on('click', function(event){
- if(headerCanvas === true){
- $('#pseudobody').animate({top:'-216'});
- $(document).css('height', $(document).height() - 216);
- headerCanvas = false;
- }
- else if(headerCanvas === false){
- $('#pseudobody').animate({top:'0'});
- $('#pullDownTab').fadeOut();
- headerCanvas = true;
- }
- });
I'm trying to run some jQuery code, for now let us say a simple javascript alert, when the first element that is draggable is dragged amongst many draggable elements.
So one alert would be fired when the first drag happens, but every drag after that another alert happens.
Here is how I am trying to do it:
var firstTimeHappened = false; $('.dataCard').draggable({ axis: 'x', revert: true, drag: function(event, ui){ event.preventDefault(); if($(event.target).is('.dataCard')){ if(firstTimeHappend === false){ // first time has not yet happened alert("first drag"); firstTimeHappened = true; } else{ // first drag has already occurred alert("drag that is not first"); } } } });
So I have a variable that turns true when the first drag occurs. If it is false, then this drag must be the first drag so I run the first-drag alert. If it is true, then the first drag has happened so the not first drag alert happens. The issue I am getting with this is that the error console says that firstTimeHappened is not defined.
Why is that and how can I fix that?
or
How can I detect the first drag and do one thing in that case and something else in all other cases?
- 07-Apr-2013 05:25 PM
- Forum: Using jQuery
I am trying to fade an element, #topNav, in when the scroll-bar goes down and then fade it out when the scroll-bar goes up and reaches the scrollTop.With this code, it fades in on scrollDown and when it hits the top.- $(document).ready(function(){
- function scrollFunc(e) {
- if ( typeof scrollFunc.x == 'undefined' ) {
- scrollFunc.x=window.pageXOffset;
- scrollFunc.y=window.pageYOffset;
- }
- var diffX=scrollFunc.x-window.pageXOffset;
- var diffY=scrollFunc.y-window.pageYOffset;
- if(diffX<0){
- // Scroll right
- }
- else if(diffX>0){
- // Scroll left
- }
- else if(diffY<0){
- // Scroll down
- $('#topNav').fadeIn();
- }
- else if(diffY>0){
- // Scroll up
- if(document.body.scrollTop === 0){
- $('#topNav').fadeOut();
- }
- }
- else{
- // First scroll event
- $('#topNav').css('position','fixed').show().fadeIn();
- }
- scrollFunc.x=window.pageXOffset;
- scrollFunc.y=window.pageYOffset;
- }
- window.onscroll=scrollFunc;
- });
- Hello,I was doing some research on changing the type of an <input /> using jQuery and I found multiple answers saying that jQuery forbids this as it doesn't work in IE.However, I tried it and it is working. Meaning, it doesn't throw an error and prevent me from doing it like my research said it would.Is this allowed in jQuery now? Is it supported in IE now by 1.9 ?
- 09-Feb-2013 03:31 AM
- Forum: Using jQuery
Hello,I developed an off-canvas navigation that slides in from the left on click of the list icon in the upper-left. It is powered by CSS3 Transitions when supported, but falls back to some jQuery I wrote, with a similar effect, thanks to Modernizr.I tested the jQuery and CSS separately and they both work fine individually; in fact, they both work fine when combined too in most browsers whether they support CSS3 Transitions or not.However, in IE 8 and below it is obviously relying on the jQuery fallback, which does not work. Nothing happens and there are no errors.I am using jQuery 1.9 which still has support for IE 6+, but this script doesn't work in IE 8 and less. It works fine in IE 9. And then in IE 10 too, but because of the CSS3 Transition support.I would greatly and sincerely appreciate all and any help in getting this to work in the legacy versions of IE.Thanks in Advance!- Hello,I am using JQuery as a fallback for a CSS3 accordion. Upon testing what I thought was supported jQuery, I realised that the script does not work in IE 8 through 6 and less than iOS5.By not working, I mean that the slides / panels do not open upon click.I also added a test, which is an alert to see if event e is being caught on the "tap / click" as it should according to the code.The event is not being caught in the browsers that do not support the script (IE 8 - 6 and iOS 5 and less) and I believe this is what is causing the slides not to open.Can someone help me fix my code so that it works in IE 8 through 6 and iOS ?I would really appreciate any and all help!Here is my code right now:
$(document).ready(function(){ var input = $('.ac-container input'); input.bind('tap click', function(e) { alert( e.currentTarget.nodeName ); var me = $(this).siblings('article'); if(!me.is(':animated')) { me.slideDown().parent() .siblings().children('article').slideUp(); } }); }); Thanks in Advance & Best Regards!- 23-Oct-2012 04:38 PM
- Forum: Using jQuery
Hello,I wrote some jQuery to power an accordion and I am confused and stumped on why it doesn't work in iOS or Internet Explorer.
Here it is:
- $(document).ready(function(){
- var input = $('.ac-container input');
- input.bind('tap click', function() {
- var me = $(this).siblings('article');
- if(!me.is(':animated')) {
- me.slideDown().parent()
- .siblings().children('article').slideUp();
- }
- });
- });
And by not working, I mean that theare not sliding down on click or tap. I would really appreciate any and all help in solving this and to get it working in IE and in iOS. Thank you in Advance! - 22-Oct-2012 02:04 PM
- Forum: Using jQuery
Hello,I built an accordion in css3 and it works fluently except in browsers that do not support the :checked psuedo-class.So to combat this, I thought to use jQuery to cause the content to slide-down once jQuery detected that the input / label above the content is checked.Here is the basics of my html, which should make what I am trying to do more clear:- <section>
- <div>
- <input type="checkbox" />
- <label>1</label>
- <article>
- <p> Content...</p>
- <article>
- </div>
- </section>
- <section>
- <div>
- <input type="checkbox" />
- <label>2</label>
- <article>
- <p> Content 2...</p>
- <article>
- </div>
- </section>
- <section>
- <div>
- <input type="checkbox" />
- <label>3</label>
- <article>
- <p> Content 3...</p>
- <article>
- </div>
- </section>
In the $(document).ready I first hide all the <articles> using .hide() function. But then my problems occur when I detect the input being checked and causing the article to .slideDown() if the input is checked.Of course if that input is unchecked then, then have the article .slideUp()I have tried every single way I can think of doing this so if anyone has any suggestions or code on how to get the corresponding article to be shown once the input is checked and then unshown once unchecked, I would greatly appreciate it.Thank you very much in Advance!- In developing my portfolio, I found that it takes a long time for the page to load due to all the images / screenshots.I was wondering if it is possible to postpone or prevent the loading of an element ? And then load it when something is clicked...Possible something like this is Pseudo-Code:Prevent loading of all elements with .images classon click of .title, load .images.I would really appreciate any and all help in this!Thanks in Advance!
- Hello,I wrote some jQuery and tested it. I found out that it wasn't working, so I replaced it with an alert to be alerted when the document is ready.However, when I view the page I see that the alert is never alerted even after the page fully-loads and is ready.I went into developer tools and I got an error that says, "Uncaught ReferenceError: $ is not defined" pointing to the line my $(document).ready(); is at.So this means the document.ready() is never being executed due to the above error.Can someone help me fix this so that it works like it should?I'd appreciate any and all help! :-)Here is my (few lines of) code so far:
- <script type="text/javscript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- alert("hello, world!");
- });
- </script>
Thanks in Advance!- Hello,I was hoping someone could help me understand why these few lines of js / jQuery are not working and help me fix them.What I was trying to acheive was writing a <script> just before the end of the <head>— so just before the </head> tag.Here is the js / jQuery:
- var retinaJs = document.createElement('script');
- retinaJs.type = 'text/javascript';
- retinaJs.src = 'assets/js/retina.js';
- $("head").append(retinaJs);
I appreciate any and all help.Thanks in Advance!- Hello,I was wondering why this usage of the .html() function is not working and was hoping someone can help me fix the code to get it to work.What I am trying to do is to replace one image with another image on hover of the first image and then put the second-image back off hover.Here is my code:$(document).ready(function(){$("#header_content").hover(function(){$(this).html("<img id='header_content' src='header_hover.png' alt='hover-image' />");},$(this).html("<img id='header_content' src='header.png' alt='image' />");});I would really appreciate any and all help with this!Thanks in Advance!
- Hello,I was trying to apply a z-index to put an overlay over a website i'm building using jQuery's .css() function, but when I tried the following it didn't work.By which i mean, the overlay as behind the site and according to chrome dev tools the overlay didn't have a z-index styling, which means the jQuery didn't work.Here is the code:$(document).ready(function(){$("#overlay").css("z-index","10000");});What did I do wrong?Can someone please help me understand what I did wrong and how I can get the styling to be applied via jQuery?Thanks in Advance & Best Regards!
- Is there a jQuery function that can cause an element to slide down as in fly from an edge of a screen to the location that it is supposed to be at?The slideDown(); function causes an element to start at the top of the container the element it is applied to and then roll down.I guess what I am looking for is something that would on an event slide from an edge of a screen or browser window to where it is supposed to go?Are there any functions or transitions like that?
- Is there a way to link to a specific tab in a series of jQuery UI tabs on a page. So that on page load, it loads that tab instead of the first tabs, which is usually the default tab that is loaded.So something like http://www.mySite.com/tabs.html#tab3 ?I would appreciate any help with this.Thanks in Advance & Best Regards,theirf
- 15-Nov-2010 09:52 PM
- Forum: Using jQuery
Hey guys,I was hoping someone here could help me get this simple exercise done. It invovles changing the html using jQuery when the browser is less than IE9I was messing with the .html() jQuery function that I have used before and was having some problems, but I got help in this postWith this code, it runs in all browsers:- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Replacing html with jQuery</title>
- <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
- <script>
- $(document).ready(function () {
- $('nav#mainNavigation').html('<p>The HTML has been changed because the browser you are using is less than IE 9</p>');
- });
- </script>
- </head>
- <body>
- <nav id="mainNavigation">
- <ul>
- <li><a href="#">Link 1</a></li>
- <li><a href="#">Link 2</a></li>
- <li><a href="#">Link 3</a></li>
- <li><a href="#">Link 4</a></li>
- <li><a href="#">Link 5</a></li>
- <li><a href="#">Link 6</a></li>
- <li><a href="#">Link 7</a></li>
- <li><a href="#">Link 8</a></li>
- <li><a href="#">Link 9</a></li>
- </ul>
- </nav>
- </body>
- </html>
Then, I used the conditional comment for Internet Explorer so that the code is only read if the browsers is less than Internet explorer 9. I am pretty sure and according to this my conditional comment code is fine, but for some reason when I try it in IE8, the .html() function is not executing and therefore not replacing the <u/> in the <nav> with a <p> in said <nav>Here is the code with the conditional comment:- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Replacing html with jQuery</title>
- <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
- <!--[if lt IE 9]>
- <script>
- $(document).ready(function () {
- $('nav#mainNavigation').html('<p>The HTML has been changed because the browser you are using is less than IE 9</p>');
- });
- </script>
- <![endif]-->
- </head>
- <body>
- <nav id="mainNavigation">
- <ul>
- <li><a href="#">Link 1</a></li>
- <li><a href="#">Link 2</a></li>
- <li><a href="#">Link 3</a></li>
- <li><a href="#">Link 4</a></li>
- <li><a href="#">Link 5</a></li>
- <li><a href="#">Link 6</a></li>
- <li><a href="#">Link 7</a></li>
- <li><a href="#">Link 8</a></li>
- <li><a href="#">Link 9</a></li>
- </ul>
- </nav>
- </body>
- </html>
Does anyone have any idea why it is not executing the function in the condition comment when it is run in a version of IE less than 9 like it is supposed to.Is it possible that maybe the script should be in a separate file and just be linked?Is there a conflict between the JQuery syntax and the condition comment?I hope someone could help, I would appreciate it a lot as I have to get this done soon.Thanks in Advance & Best Regards- Hello guys,Can someone please tell me why and help me fix this example of the .html() jQuery function.What I am trying to do is execute a change in html inside a IE conditional statement.Here is my code:<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><title>Replacing html with jQuery</title><!--[if lt IE 9]><script src="http://code.jquery.com/jquery-1.4.4.js">$(document).ready(function () {$('nav#mainNavigation').html('<p>The HTML has been changed because your browser is less than IE 9.</p>');});<script><![endif]--></head><body><nav id="mainNavigation"><ul><li><a href="#">Link 1</a></li><li><a href="#">Link 2</a></li><li><a href="#">Link 3</a></li><li><a href="#">Link 4</a></li><li><a href="#">Link 5</a></li><li><a href="#">Link 6</a></li><li><a href="#">Link 7</a></li><li><a href="#">Link 8</a></li><li><a href="#">Link 9</a></li></ul></nav></body></html>And then I thought that possibly the DOM need the #mainNavigation loaded first before it can execute the script since the script is looking for it and replacing its inner contents, so I did this:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Replacing html with jQuery</title>
- </head>
- <body>
- <nav id="mainNavigation">
- <ul>
- <li><a href="#">Link 1</a></li>
- <li><a href="#">Link 2</a></li>
- <li><a href="#">Link 3</a></li>
- <li><a href="#">Link 4</a></li>
- <li><a href="#">Link 5</a></li>
- <li><a href="#">Link 6</a></li>
- <li><a href="#">Link 7</a></li>
- <li><a href="#">Link 8</a></li>
- <li><a href="#">Link 9</a></li>
- </ul>
- </nav>
- <!--[if lt IE 9]>
- <script src="http://code.jquery.com/jquery-1.4.4.js">
- $(document).ready(function () {
- $('nav#mainNavigation').html('<p>The HTML has been changed because your browser is less than IE 9.</p>');
- });
- <![endif]-->
- </script>
- </body>
- </html>
I know the conditional code is write, but essentially my problem is get the .html() function to work properly. So regardless of the browser conditional statement, in this sample, why doesn't this work:- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Replacing html with jQuery</title>
- </head>
- <body>
- <nav id="mainNavigation">
- <ul>
- <li><a href="#">Link 1</a></li>
- <li><a href="#">Link 2</a></li>
- <li><a href="#">Link 3</a></li>
- <li><a href="#">Link 4</a></li>
- <li><a href="#">Link 5</a></li>
- <li><a href="#">Link 6</a></li>
- <li><a href="#">Link 7</a></li>
- <li><a href="#">Link 8</a></li>
- <li><a href="#">Link 9</a></li>
- </ul>
- </nav>
- <script src="http://code.jquery.com/jquery-1.4.4.js">
- $(document).ready(function () {
- $('nav#mainNavigation').html('<p>The HTML has been changed.</p>');
- });
- </script>
- </body>
- </html>
I would really appreciate it if someone could help me learning how to properly use the .html() function.Thanks in Advance & Best Regards.- «Prev
- Next »
Moderate user : xmasmi
© 2013 jQuery Foundation
Sponsored by
and others.