I'm currently working on a website, which has a page with 2 big images (combined around 9000px) in them. The idea is that people can click and drag, to see the sides of the image, just like google maps.
At first I built it with just the 2 images next to each other. When animating the parent div on drag, I managed to only get a composite paint once in a while, but no actual paint (draws). I did this by editing the translate3d on the mouse events.
This all worked like a charm and very smooth, until I added an extra div to the parent. Now when I change the translate3d, it has to do a complete recalculate style -> layout -> paint -> composite layers.
So at first the structure was:
<div class="container" style="transform: translate3d(-50%)">
<img src="path/to/img.jpg"><img src="path/to/img.jpg">
</div>
When changing the translate3d, all was good, just had a Composite Layers once in a while.
However, when I change it to the following, all goes bananas:
<div class="container" style="transform: translate3d(-50%)">
<img src="path/to/img.jpg"><img src="path/to/img.jpg">
<div>+</div>
</div>
So like said before, now when editing translate3d, it has to do a complete Recalculate style.
I made sure the div and images both had layers by adding translateZ(0) on them, that didn't help though :(
I'm pretty sure I don't understand the whole paint sequence of chrome to the detail, but after countless hours of reading I can't find the exact thing. I hope someone can shed some light on this matter.
Thanks a bunch!
Edit after Paul's reply:
The Recalculate Style is triggered by the following line:
this.background.style.transform = 'translate3d(' + (this.panoramaX - this.previewOffset) + '%, 0, 0)';
Related
Playing with impress.js
I'm trying to acheive a Reveal.js like slide transition, but using impress.js.
The basic effect did come, but i feel, the slides are taking a 'wider' turn making it look a lil slower.
Note : In the fiddle, maximize the output section to see the said problem more clearly
I dont know how else to put it, but if you see http://lab.hakim.se/reveal-js/#/fragments and
http://jsfiddle.net/8ukwex3x/1/, you will be able to make out the difference.
<div id = "impress">
<div class = "step">
Slide 1
</div>
<div class = "step" data-x = "500" data-z="-400"
data-rotate-y="90">
Slide 2
</div>
</div>
What should I do to make it work just like Reveal.js' transition.
Unfortunately your fiddle is completely missing the JavaScript (where I assume you had intended to put just the standard impress.js code) and in any case, just reading from the source code I don't see how your example is in any way similar to what the reveal-js example does. So, with the risk that I might be completely off here, I have one thing that may hopefully be helpful...
The reveal.js transitions are indeed pretty slick and fast. Did you know that you can set the duration of a transition in impress.js? The attribute is data-transition-duration:
<div id="impress" data-transition-duration="1000">
A demo slide show that uses it here.
The default is 1000 ms. A value at about 400-600 ms should give you the reveal.js experience in terms of speed.
PS: Note that in my impress.js repo, where the above link is to, you can also set a duration for each individual step/slide. For the upstream impress.js, all slides have the same duration, set in the root div element.
If you go to a page like youtube.com and drag the mouse around while holding down the left button all kinds of things get selected. In the image below, for example, I'm just dragging the mouse along the red arrow and all the stuff at the top got selected and turned blue.
But if I create a jsfiddle - http://jsfiddle.net/nxwLc/ - with a simple div and drag the mouse around with the left button down, I'm not able to select anything. I can even drag completely around the box without selecting it.
Does anyone know what the difference is?
Thanks
<div id="box1"></div>
The selection (highlight) you see is being applied to textual content elements specifically text and images. In your example you have nothing but a <div> element
Now you'll have something to highlight: http://jsfiddle.net/nxwLc/2/
<div id="box1"><img src="//placehold.it/100x100/cf5"/> asdasdasd</div>
Also worth noting that Firefox will highlight exactly what should be highlighted, while in Chrome the highlight area will have unspecific and also unpredicted results, element-related, keeping an eye to line-heights content-flows etc... strange in any case.
Chrome vs. Firefox
I'm trying to figure out a way to have two href's attached to a single image, sort of like an old school image map, but just using CSS. Is this even possible?
Currently the HTML looks like this. But I'm being ask to have two URL's attached based on where the user is hovering their mouse.
<div id="logo-wide">
<img src="BIG-Logo_FINAL.png" alt="url-name">
</div>
Philip
You'll have to either
Use an image map
Slice the image in half and wrap each half in a link
Use z-index to hover two absolutely positioned links over the images (this would be really hackish and ugly)
Option 1 or 2 is best.
Usless Background Info
Hello, all. This is my first post here, but I often come here for help.
I am an amateur web designer and have been in web designing for almost a year now.
The Problem
My question is about CSS3 transforms. I have a small, circular element in the center of my page that transforms successfully when I hover over it. I have a larger circular element that is, by z-index, underneath it. The larger circle also has CSS3 transforms coded in the CSS, but will not transform, or even triggerd when hovered over. Both circles are overlaid, with the smallest on top, to create concentric circles.
My Attempted Solution
One word: Z-index. I have tried putting the larger circle on top, which works fine. The problem with this is that the smaller circle no longer triggers...
The Result I Want
I would like for the circles to remain in their 'concentric' positions and for the larger circle on the outside to transform by :hover. Is it possible to have an 'alternate trigger'? e.g.: in JavaScript, I can trigger an animation by hovering over any element that I specify. Is this possible to do in CSS? Can I hover element (I), and change properties for element (II)? If I cannot do this, how would I go about triggering animations for both circles, by hovering over only one? I am trying to stay with pure CSS/HTML, but I will accept JavaScript answers.
Last Notes
I hope I have provided ample info for a decent answer... Here is a screenshot: http://i.stack.imgur.com/WPj62.png
The circle with the infinity sign is the smaller circle element. The larger circle with the faint border around the screen is the other element.
EDIT:
Something's still not right, please take a look at the full code posted here: http://cssdesk.com/eJ8BH
If I understand your question, it sounds like when you hover over the small circle, you want both the large and small circle to transform, correct?
The easiest way is likely to use javascript for this. If you are using jQuery, it's even easier:
$('.littleCircle')
.hover(function(){
$(this).addClass('myTransformationClass');
$('.biggerCircle').addClass('myTransformationClass');
})
UPDATE: Some further examples based on follow-up feedback.
Here's what I'd do. First, give all 4 related elements a class so you can grab them via jQuery. For the example I use .rolloverSet
// grab all 4 elements and cache them
$rolloverSet = $('.rolloverSet');
// grab the one element that needs to have two classes
$otherElement = $rolloverSet.find('.otherElement');
$rolloverSet
.hover(function(){ // we'll add a hover event to each element in the group
$(this).addClass('myTransformationClass');
$otherElement.addClass('myOtherTransformationClass');
})
.blur(function(){ // remove the classes on mousout
$(this).removeClass('myTransformationClass');
$otherElement.removeClass('myOtherTransformationClass');
})
You do not need jQuery for this. You need to apply :hover on the parent element of the concentric circles and then apply the animation to its immediate children like this: http://jsfiddle.net/nimbu/taqr4/
Things I changed:
Updated to use shorter transitions, animations property
Added moz, o, unprefixed properties
Removed -webkit- from border-radius
Gathered common properties of concentric circles to prevent repetition
Fixed incorrect background-color (#00000000)
I'm trying to create a gray "frame" (see pic below) around a google map, to try to convey the concept of an area of focus, as oppose to a point (which is usually represented with a marker). Note that this is not an overlay, that is, the gray "frame" should not move when you drag the map.
Edited: image link added
It appears that only option is to "subclass" GControl to create a custom control. I have 3 questions
1) First of all, is GControl subclassing the best course of action?
2) In my example, the canvas (div) where map renders can change its size (i.e is not fixed width). Do I have to delete and add custom control when canvas changes size? See docs http://code.google.com/apis/maps/documentation/controls.html#Custom_Controls on how to create a custom map control.
3) Now, how to do it. Naively, I thought I could create a table with 3 columns and 3 rows, and set display: none for the cell in the middle. But that doesn't work. I've also experimented with clipping, that didn't work either. My css skills are quite lacking, so there must be way to do this more elegantly than adding four rectangular gray divs. If I wanted to add an inner border, with divs, I would need to paint 8 then. In a nutshell, what's the best way to create a "hollow" rectangle?
Thanks
P.S. This is my first entry to StackOverflow. Just discovered it. It's impressive how well SO is put together.