Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Adding a Mouse with Easing & Direction


Question

14 answers to this question

Recommended Posts

  • 0
<!--Image grabbed from: http://www.giantbomb.com/astro-boy-omega-factor/3030-2253/characters/-->
<div id="bee"> 
  <img src="//content.invisioncic.com/p289038/monthly_2021_04/2042369419_mouserov.png.780f6ae1eb5d64a63dcbd0a02dc08f49.png"   />
</div>
<style>.left {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
.right {
        -moz-transform: scaleX(1);
        -o-transform: scaleX(1);
        -webkit-transform: scaleX(1);
        transform: scaleX(1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
#bee {transition: transform .1s}</style>
<script>
     var bee = document.getElementById("bee");
		document.addEventListener("mousemove", getMouse); 


		bee.style.position = "absolute"; //css		
		var beepos = {x:0, y:0};

		setInterval(followMouse, 50);
		
		var mouse = {x:0, y:0}; //mouse.x, mouse.y
		
		var dir = "right";
		function getMouse(e){
			mouse.x = e.pageX;
			mouse.y = e.pageY;
        //Checking directional change
        if(mouse.x > beepos.x){
          dir = "right";
        } else {
          dir = "left";
        }
		}
		
		function followMouse(){
			//1. find distance X , distance Y
			var distX = mouse.x - beepos.x;
			var distY = mouse.y - beepos.y;
			//Easing motion
       //Progressive reduction of distance 
			beepos.x += distX/5;
			beepos.y += distY/2;
			
			bee.style.left = beepos.x + "px";
			bee.style.top = beepos.y + "px";
      
      
        //Apply css class 
        if (dir == "right"){
          bee.setAttribute("class", "right");
        } else {
          bee.setAttribute("class", "left");        
        }
			
		}
</script>
7 hours ago, christina_marie_333 said:

Site URL: https://codepen.io/redspiderfish/pen/MYmeYz?js-preprocessor=none

Hi how do I add this to my website I don't know where to insert the code found in this code pen. 

 

https://codepen.io/redspiderfish/pen/MYmeYz?js-preprocessor=none

please help! however i will be changing the image to 

mouse rov.png

Create new code block and paste this content, the content type is HTML.

Heads up: the text below is long

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0
2 minutes ago, christina_marie_333 said:

Hi I am getting a syntx error? When adding that code to design custom css

 

Use advance code injection, since it has javascript code, it will require advance plan or higher

Edited by bangank36

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0
5 minutes ago, christina_marie_333 said:

this is the website it is for https://crissy-webpage-design.squarespace.com

Did you add code to settings-advanced-code injection-footer?

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0

Hello I upgraded to a higher subscription with javascript 

 

Do I had code to settings - design custom CSS

<!--Image grabbed from: http://www.giantbomb.com/astro-boy-omega-factor/3030-2253/characters/-->
<div id="bee"> 
  <img src="//content.invisioncic.com/p289038/monthly_2021_04/2042369419_mouserov.png.780f6ae1eb5d64a63dcbd0a02dc08f49.png"   />
</div>
<style>.left {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
.right {
        -moz-transform: scaleX(1);
        -o-transform: scaleX(1);
        -webkit-transform: scaleX(1);
        transform: scaleX(1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
#bee {transition: transform .1s}</style>
<script>
     var bee = document.getElementById("bee");
		document.addEventListener("mousemove", getMouse); 


		bee.style.position = "absolute"; //css		
		var beepos = {x:0, y:0};

		setInterval(followMouse, 50);
		
		var mouse = {x:0, y:0}; //mouse.x, mouse.y
		
		var dir = "right";
		function getMouse(e){
			mouse.x = e.pageX;
			mouse.y = e.pageY;
        //Checking directional change
        if(mouse.x > beepos.x){
          dir = "right";
        } else {
          dir = "left";
        }
		}
		
		function followMouse(){
			//1. find distance X , distance Y
			var distX = mouse.x - beepos.x;
			var distY = mouse.y - beepos.y;
			//Easing motion
       //Progressive reduction of distance 
			beepos.x += distX/5;
			beepos.y += distY/2;
			
			bee.style.left = beepos.x + "px";
			bee.style.top = beepos.y + "px";
      
      
        //Apply css class 
        if (dir == "right"){
          bee.setAttribute("class", "right");
        } else {
          bee.setAttribute("class", "left");        
        }
			
		}
</script>

 

Or do I add if as a code block? 

Or do I add it to the header or footer ? 

Advanced Code Injection? 

I understand the code I just don't no where to copy and paste it on the sqaurespace website? 

Thank you for your help I've been trying for months

Link to comment
  • 0

For information, I found it really difficult to reach the cart. Clicking the cart icon didn't do anything.

cannot-click-cart-icon.gif.7f974178937fcc186bd8d33b624399f9.gif

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0
On 4/11/2021 at 1:04 AM, bangank36 said:

<!--Image grabbed from: http://www.giantbomb.com/astro-boy-omega-factor/3030-2253/characters/-->
<div id="bee"> 
  <img src="//content.invisioncic.com/p289038/monthly_2021_04/2042369419_mouserov.png.780f6ae1eb5d64a63dcbd0a02dc08f49.png"   />
</div>
<style>.left {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
.right {
        -moz-transform: scaleX(1);
        -o-transform: scaleX(1);
        -webkit-transform: scaleX(1);
        transform: scaleX(1);
        filter: FlipH;
        -ms-filter: "FlipH";
}
#bee {transition: transform .1s}</style>
<script>
     var bee = document.getElementById("bee");
		document.addEventListener("mousemove", getMouse); 


		bee.style.position = "absolute"; //css		
		var beepos = {x:0, y:0};

		setInterval(followMouse, 50);
		
		var mouse = {x:0, y:0}; //mouse.x, mouse.y
		
		var dir = "right";
		function getMouse(e){
			mouse.x = e.pageX;
			mouse.y = e.pageY;
        //Checking directional change
        if(mouse.x > beepos.x){
          dir = "right";
        } else {
          dir = "left";
        }
		}
		
		function followMouse(){
			//1. find distance X , distance Y
			var distX = mouse.x - beepos.x;
			var distY = mouse.y - beepos.y;
			//Easing motion
       //Progressive reduction of distance 
			beepos.x += distX/5;
			beepos.y += distY/2;
			
			bee.style.left = beepos.x + "px";
			bee.style.top = beepos.y + "px";
      
      
        //Apply css class 
        if (dir == "right"){
          bee.setAttribute("class", "right");
        } else {
          bee.setAttribute("class", "left");        
        }
			
		}
</script>

Create new code block and paste this content, the content type is HTML.

Heads up: the text below is long

How do I stop the mouse 🐀 from tracking to far to the right 👉 moving the screen across on mobile and desktop. 

 

Please help 

 

Screenshot_20210507-134836_Messenger.jpg

Screenshot_20210507-134800_Messenger.jpg

Link to comment
  • 0
On 4/17/2021 at 11:56 PM, paul2009 said:

For information, I found it really difficult to reach the cart. Clicking the cart icon didn't do anything.

cannot-click-cart-icon.gif.7f974178937fcc186bd8d33b624399f9.gif

Would you know how I can stop the mouse 🐀 from tracking to far to the right 👉, as requested in few post 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...