Spin the connections around a circular path

I'm interested in creating a website where links rotate around a circle, similar to this example: https://i.sstatic.net/103mx.jpg. The links will display different images and texts leading to various URLs. I want the images to form a unified rotation effect as the user scrolls. Is there a way to achieve this? Additionally, is it possible to make the page height infinite so that users never reach the bottom of the page as they scroll? Thank you for any assistance!

Below is the jsfiddle link and code that enables the image rotation functionality. http://jsfiddle.net/kDSqB/135/

var $cog = $('#cog'),
    $body = $(document.body),
    bodyHeight = $body.height();

$(window).scroll(function () {
    $cog.css({
        'transform': 'rotate(' + ($body.scrollTop() / bodyHeight * 30000) + 'deg)'
    });
});

Answer №1

http://jsfiddle.net/Fezjh/1/

To enhance understanding, I have color coded the div, though it is vital to address compatibility concerns (especially with older browsers).

Simply removing the background color will achieve your desired effect.

An improved approach would be to divide the image into separate divs and align them closely together.

Visit http://www.gdrtec.co.uk - observe how 4 images are seamlessly connected in the start menu; rotating the containing div would not disrupt functionality.

The code example provided is merely for demonstration purposes and should be substituted with a more resilient solution.

$('#link1').click(function(){
    alert("openURL");
});

Additionally, ensure that your website does not necessitate JavaScript for basic functionality.

Answer №2

Check out this: http://jsfiddle.net/F8GTP/, and the final version can be found here: http://jsfiddle.net/MjnxP/.

To implement infinite scroll using WheelEvent, follow these steps:

var $cog = $('#cog'),
    $body = $(document.body),
    bodyHeight = $body.height(),
    rotate = 1;

var wheelEvent = function (event) {
    var delta = 0;
    if (event.wheelDelta) { delta = event.wheelDelta/120; } else if (event.detail) { delta = -event.detail/3; }

    if (delta) {
        rotate += delta * 1.12; //<== Increase speed.
        console.log(rotate, delta);
        $cog.css({ 'transform': 'rotate(' + rotate + 'deg)'});
    }

    if (event.preventDefault) { event.preventDefault(); }
    event.returnValue = false;
};

window.onmousewheel = wheelEvent;
if (window.addEventListener) { window.addEventListener('DOMMouseScroll', wheelEvent, false); }

To detect links, use a canvas with "collision image", and here is the final version:

$cog.click(function(e) {
    if (rotate !== lastrotate) {
        
        context.save();
        context.translate((image.width/2), (image.height/2));
        context.rotate(rotate * Math.PI/180);
        context.drawImage(image, -(image.width/2), -(image.height/2));
        context.restore();
        lastrotate = rotate;
    }

    var x = e.pageX, y = e.pageY;    
    console.log(x, y);

    var color = context.getImageData(x, y, 1, 1).data;
    
    if (color[0] == 255 && color[1] == 255 && color[2] == 255) { 
        alert("click");
    }
});

// Other code for setting pixel and working with canvas

Ensure to use your own domain image for "image.src" or convert it to Base64 to avoid security errors. You can use this tool to convert image to Base64: .

If the position of the cog is not at (0, 0), adjust the code accordingly:

var x_pos = 200, y_pos = 200; 
var x = e.pageX - x_pos, y = e.pageY - y_pos;  

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you explain the distinction between data-ng and ng?

I recently came across a discussion about the distinction between ng-* and data-ng-* in AngularJS. Apparently, using data-ng-* ensures that the HTML remains valid. But I can't help but wonder, why is this necessary when I can simply declare the ang ...

Changing the dynamic boundaries does not produce any results in the 'react-leaflet' library

Encountered an issue while trying to utilize the react-leaflet's bounds property. In my scenario, the application has predefined initial bounds in the state (referred to as fallback bounds) which are passed during the first component render. The archi ...

JavaScript button click changes the selected row's color in a DataTable

I am looking to dynamically change the color of a row in my Datatable when a specific button is clicked. Here is the HTML code snippet for the rows: <tr role="row" class="odd"></tr> <tr role="row" class="even selected"></tr> & ...

Tips for arranging two svg elements next to each other within a larger div

Hey everyone, I've been working on some HTML and JavaScript but I'm stuck on a basic issue. I have a simple code with a div containing two inner divs, each with an SVG element equal to the size of the parent div. My goal is to have these two inne ...

Toggle button visibility on ng-repeat item click

Hello everyone, I'm encountering an issue with displaying and hiding buttons in ng-repeat. <div class="row" ng-repeat="item in items"> <button type="button" ng-click="add()">+</button> <button type="button" ng-click="remo ...

Combining user input with React's useState function

I have a form with three Quantity inputs. (Although more can be added dynamically, let's keep it simple for now and stick to three.) | - | - | Quantity | |---|---|----------| | - | - | 3 | | - | - | 4 | | - | - | 5 | Now, I want ...

React's Dynamic Table fails to rerender when updated values are placed in the same row and under the same header

Here is the table generated by my functional component: <table class="table"> {/* Consonant Table */} <tr> <th colSpan="2">---</th> {headersPOA. ...

Using Angular 7 shared service to allow sibling components to exchange data between each other

In my Angular 7 application, I have two sibling components - a configurator component and a custom stepper component. The configurator component is responsible for fetching data from the API and performing calculations on it. I would like to display the ca ...

Tips for sharing a variable with an external JavaScript file in ASP.NET

Utilizing the variables from default.aspx.cs within the script of the default.aspx file has been achieved successfully with the following code: public partial class default: System.Web.UI.Page { public string _file = string.Empty; public string _i ...

passport not initializing session with requests

I am currently utilizing passportJS for managing login and persistent sessions on the server backend. While everything functions properly when sending requests from the server frontend (a webpage that I didn't create and lack sufficient knowledge to ...

What is the best way to use `JSON.parse` in jQuery to accommodate older browsers?

Is there a way to internally call the function in jQuery that performs JSON.parse? I need to support IE8 and IE9, which don't have JSON.parse available. This means I can't simply use it in my code, so I'll have to rely on an external librar ...

Adjust the height of a div element back to its original size using jQuery after it

My goal was to create a dynamic div that expands when the user clicks on it, revealing more information. I have successfully achieved this functionality. However, my next objective is to modify the script so that the height of the div changes back when the ...

Space in the middle of a body and a div

After extensively searching for a solution to the issue plaguing my website, I found that there was always an annoying gap at the top of the page. Despite trying various solutions, none seemed to work. Upon inspecting the website in Firefox, I discovered t ...

Tips for showcasing checkbox options on an HTML page (utilizing ejs) following the retrieval of information from MongoDB and making it editable for the User

Currently, I store data in mongo for a multiple-choice question and indicate the correct answers. In mongo, I save them like this: question.options.option1.check = "on" for the correct answers. When I navigate to the "edit" page, I retrieve the specific ...

"Adjust the orientation of a video and ensure it properly fills the screen with CSS styling

Below is the CSS style being used: video { position: absolute; transform: rotate(90deg); width: 100%; height: 100%; z-index: 4; visibility: visible; } This code snippet demonstrates a video element: <video id="myVideo" ...

Trigger a notification from one webpage to another (PHP, JavaScript, HTML)

I'm currently working on a website that consists of both a receptionist page and a user page with multiple logins. The receptionist page displays a table listing all logged-in users, including their status (either ready or busy). This table is refresh ...

Remove the input box for submission from the HTML code

How can I remove the 'button' from my input field and replace it with an image? Even after trying different methods, the box still appears. Thank you. <!DOCTYPE html PUBLIC ""> <head> <style> #PlusMinus{background:url(&apo ...

What seems to be the issue with this particular jQuery collection?

Perhaps something quite simple but I am having trouble figuring it out. Below is the command that returns a json array. var zz = fm.request({ data : {cmd : 'url', target : hash}, preventFail : true, op ...

The container is hugging the edges of the screen a little too closely in Firefox

Using Bootstrap 5.0.2, I've implemented custom CSS with the code snippet below: @media (min-width: 1680px) { .container, .container-fluid { box-sizing: border-box !important; max-width: 1750px; } } When viewing the page on Chrome, every ...

Tips for updating process.version in a Node.js environment

After upgrading my node version from v3 to v11 using nvm with the command nvm use 11.12.0, I noticed that when I check the version using node -v in the terminal, it correctly shows 11.12.0. I also have a node js application that is started through pm2. I ...