Click and Rotate for More Information

Hello everyone, I have a question regarding creating a unique Tumblr theme. My goal is to make the posts rotate on the y-axis when clicked, revealing like and reblog information. Currently, I've been able to achieve this effect on hover by using code from a specific source but now I need assistance in implementing it for click events instead. I've tried some tutorials involving JavaScript and jQuery without success. Can someone kindly guide me through this process in simple terms as I'm new to these programming languages? Your help is greatly appreciated! Below is a snippet of my CSS:

    #f1_container {
  position: relative;
  margin: 10px auto;
  width: 250px;
  z-index: 1;

  perspective: 1000;
}
#f1_card {
  width: 250px;
  transform-style: preserve-3d;
  transition: all 1.3s linear;
}

#f1_container:hover #f1_card {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  backface-visibility: hidden;
}
.face.back {
  position: absolute; 
  transform: rotateY(180deg);
  background-color: {color:Text};
  width: 250px;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  text-align: center;
}

...and here is an excerpt of my HTML:

{block:Photo}
{block:IndexPage}
<div id="f1_container">
<div id="f1_card">
  <div class="photo"><div class="front-face"><img src="{PhotoURL-250}" alt="{PhotoAlt}"> </div></div> <div class="back face center">
<div class="perm"><span class="like"style="padding-right:7px">{LikeButton color="grey" size="13"}</span> <span class="rb" style="padding-left:5px;">{ReblogButton color="grey" size="13"}</span> <span class="noteslabel" style="padding-right:5px;"><a href="{Permalink}" target="_blank">{NoteCount}</a></li></ol></div>
  </div>
</div>
</div>
{/block:IndexPage}
{block:PermalinkPage} <img src="{PhotoURL-500}" alt="{PhotoAlt}"> {/block:PermalinkPage} {/block:Photo} 

Just to give you a glimpse, here's a link to my site: . It might seem messy right now as it's where I test my themes in progress.

Answer №1

It's my understanding that Tumblr does support the integration of jQuery and Javascript. To enable jQuery in your file, simply include this at the beginning:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

After doing this, you can start using jQuery by creating a click function like so:

var r=0;
$(document).ready(function() {
    $('#Image-ID-or-DIV').click(function(){   
        $("#Image-ID-or-DIV").css("transition", "500ms linear all");                    
        $("#imgs").css({transform: 'rotateY(' + (r += 180) + 'deg)'});
    });
});

1) Setting r=0 is crucial for resetting the animation once it completes.

2) The document.ready function is a fundamental part of jQuery, nothing too complex.

3) This snippet indicates that when a specific image with an ID is clicked, a function will be triggered.

4) By specifying the transition duration to be 500 milliseconds, the rotation effect will appear smooth and gradual upon clicking the image.

5) The actual image rotation occurs here based on the specified degree value. Refer to documentation for more details.

If you wish to add additional CSS styling when the image is clicked, you can do so by including:

$("#Image-ID-or-DIV").css('[place your CSS here]')

It's recommended to consult documentation regarding the proper usage of jQuery .css() method.

I trust this information proves helpful to you!

Answer №2

I believe Ramsay was heading in the right direction by using :focus. To improve, consider enclosing f1_container within an anchor tag like so:

<a href="#" class="focus-wrapper"> <!--also avoid reusing IDs - they should be unique-->
  <div class="f1_container"> 
     <!-- insert code here -->
  </div>
</a>

Furthermore, eliminate any special anchor styles as recommended in HTML Anchor, Disable Style:

.focus-wrapper:hover, .focus-wrapper:visited {
   text-decoration: inherit;
   color: inherit;
   cursor: auto;
}

Create a rule to apply changes on focus:

.focus-wrapper:focus .f1_container .f1_card {
   transform: rotateY(180deg);
}

Don't forget to remove the browser's focus outline:

.focus-wrapper:focus {
   outline:none;
}

If it isn't clear, remember to remove the existing rule that resembles:

#f1_container:hover #f1_card {
   transform: rotateY(180deg);
}

See an example here: http://jsfiddle.net/yb9exv9b/

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 show me how to achieve a smooth background color transition for a div that takes 2 seconds to complete when it is inserted into the DOM?

On my webpage, I have a list of items that are constantly being updated via a WebSocket connection to the backend. Each time a new item is added to the list, I would like it to be displayed with a background color transition lasting only a brief moment. ...

Organizing an array based on designated keywords or strings

Currently, I am in the process of organizing my logframe and need to arrange my array as follows: Impact Outcomes Output Activities Here is the initial configuration of my array: { id: 15, parentId: 18, type: OUTPUT, sequence: 1 }, { id: 16, parentId: ...

Place the object into a vacant area with the help of jQuery Sortable

I am using jQuery Sortable and it's functioning well. However, I have encountered a small issue that I need help with.    I have two blocks where elements from one block can be moved to the other. The problem arises when all the elem ...

Several features - Second function malfunctioning

The initial inquiry is effective. However, the subsequent one is encountering issues as it is failing to confirm if an email contains the "@" symbol. My attempted solution involved reordering the functions related to email validation. <body onload="ch ...

Unexpected Timed Out error from Socket.IO adapter when MongoDB connection is lost

I have been experimenting with capturing the disconnection event in mongodb. Everything is working smoothly with this setup: simple.js 'use strict'; var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:2701 ...

Creating distinct identifiers for CSS JQ models within a PHP loop

Can anyone assist me in assigning unique identifiers to each model created by the loop? I am currently looping through a custom post type to generate content based on existing posts. I would like to display full content in pop-up modals when "read more" i ...

Tips for generating a JSON string with nested structure

Can someone assist me in generating a JSON based on the HTML elements provided below? { "AppName": "ERP", "ModuleDesc": [ { "Name": "Payroll", "AcCESSRIGHTS": [ { "Create": "Y", "Retrive": "Y", "U ...

"Failure in bundling with NodeJS using nexe and fusebox

I am attempting to convert a nodejs application into an .exe file. I initially tried using pkg, but encountered errors with half of the node-modules. Now, I am experimenting with a different method. However, when I run the following command: nexe index.js ...

Fixing blurry text on canvas caused by Arbor.js mouse event issues

Currently, I am utilizing arborjs in my project. The text within the canvas is created using fillText in html5. While everything functions correctly on a Retina display MacBook, the text appears blurry. To address this, I applied the following solution: v ...

% unable to display on tooltip pie chart in highcharts angular js

https://i.stack.imgur.com/Ccd7h.png The % symbol isn't displaying correctly in the highcharts ageData = { chartConfig: { options: { chart: { type: 'pie', width: 275, height: 220, marginTop: 70 ...

When using PHP's `json_encode()`, don't forget to append a "1" at the

While utilizing json_encode in my project, I have encountered an issue that is perplexing. On one particular page where I make an ajax call, the resulting json seems to mysteriously add a 1 to the end of the string. The output of my return string appears ...

100% width with a pixel offset

In the past, I have achieved this by using padding. The concept is to have two div elements positioned side by side, where one has a width of 100% and the other has a fixed width of 50px. Here's a rough illustration: ------------------------------- ...

Transferring scope between pages without the need for an angular service definition

Looking to open a new JSP page while passing the $scope in order to utilize an array response generated in the initial page. Example from test.js file: (function() { 'use strict'; angular .module('test', []) .control ...

Error: The Google Translate key is not found in the Node.js AJAX request

I have a basic Node.js script that functions properly when executed locally in the terminal: exports.google_translate = function (translate_text, res) { var Translate = require('@google-cloud/translate'); var translate = new Trans ...

Substitute the images with links provided in an external text file

I have a function that I use to replace avatars of players with custom images. Currently, I have three replacement links hardcoded into a Chrome extension. However, I want the function to read an external txt file to dynamically build an array so that I ca ...

The issue with triggering button events in JavaScript

I've integrated a jquery modal popup for saving uploaded files related to a specific device. The modal appears, the cancel button functions correctly, but I am struggling to trigger the onclick event for the Save button... This is what I have impleme ...

Trigger a jQuery event when a value is changed

Greetings everyone, I am currently seeking a method to trigger an event each time the values change. Within a div element, there is a live clock that is constantly running: <span id="LiveClockIE">The current time is: 9:37:24 AM</span> I am l ...

Modifying the data attribute within the div does not result in a different image for the 360-degree spin view

My current project involves utilizing js-cloudimage-360-view.min.js to create a 360-degree view of images. I have successfully retrieved the images, but I am encountering difficulty in updating the images by clicking a button. index.html <!DOCTYPE html ...

Exploring the different ways to compare data with the load() method

I am faced with a coding dilemma. I have two pages: data.php and index.html. The data.php page contains a single value (let's say 99), while the index.html page uses jQuery to dynamically load the data from data.php into a div called "data" every 2 se ...

Transitioning the slider after displaying the full image

Currently, I am utilizing the Supersize slider for my project. However, I have encountered an issue where if an image is large and takes time to load, the slider transitions to a new image before the previous one has fully loaded. I am looking to impleme ...