Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am killing my neurons trying to figure out how to do this website's navigation bar with css transitions or animations: http://tabu.realitatea.net/ .
Does anybody know how to do it ? or even give me a starting point ?
This was pretty fun to make, check it out. https://jsfiddle.net/6brsm2zt/
JS
var slider = $('#slider');
$('div').on('mouseenter','a',function(){
var box = $(this);
var p = box.position();
slider.animate({
width: box.outerWidth(),
left: p.left,
},250);
})
$('div').on('mouseleave','a',function(){
slider.stop();
})
$('div').on('mouseleave',function(){
$('#slider').animate({
width: 0,
left: 0,
},200);
})
The basic idea is to have a zero width div on the left, let's call it a slider. When you mouse over an item, you set the width and left position of the slider to be equal to the width and left position of the item. The duration of the animation is quite short, about a third of a second, to give the feeling of responsiveness.
When you mouse off the bar entirely, just set the width and left position of the slider to 0 with a short duration, say 200 ms, and it'll zoom off to the side.
One tricky part is when you wave the mouse back and forth. Originally, the div would play the transition for each item, leaving me waiting for the slider to finally come to my mouse. I solved this by cancelling the animation when i mouse off an item. Since the event order for mousing between items is mouseenter -> mouseleave -> mouseenter, i already had a transition for mouseenter ready to go. Now the slider will chase your mouse relentlessly :D.
Related
I'm working on an Angular 8 project, using Material. I've searched SO and google for solutions on how to what I want, but my search has been futile.
I also went through How to customize mat-select dropdown position? but my question is different. That question seems to be more about the position of the popover. The solutions there are about positioning the menu below or above but not over the trigger element
I guess, my question is more about the direction of the popover. I would like to only drop down and not drop up. I don't know if, I'm making enough sense here...lol
Current Behavior:
When a user opens the mat-select it pops up the options 1. Over the element (like somehow in the middle). 2. It positions the rest of the options either above or below the element, depending on the scroll position (or rather element's position on screen).
The Problem right now: When it pops up above the element, the options are getting rendered out side the screen.
Wanted Behavior:
When user clicks the mat-select, 1. it pops up options BELOW the element. 2. Despite the element position, options are ALWAYS show below. Like a dropdown, never a drop up.
Sort of like how you can choose to use a dropdown or drop up with Bootstrap
Thank you in advance for you assistance and suggestions.
I'm using the mat-slide-toggle element from Angular Material 2, and I made it a bit bigger, but the thumb doesn't move to the end of the container when clicked, and I can't seem to figure out which transform-translate property controls the distance.
The following is a pic of how it looks currently when clicked:
Is someone aware of what property needs to be changed for this to slide to the end? Thanks in advance.
In case someone Googles this - the correct selector is the following:
.mat-slide-toggle.mat-checked .mat-slide-toggle-thumb-container {
transform: translate3d(64px,0,0) !important;
}
I got the correct answer from the following link, which contains other useful selectors for mat-slide-toggle.
I'm trying to use CSS transforms to make the center object in a carousel have more focus/attention. (Carousel is Slick.js)
Everything works great, except when I go from the last item back to the first item, there is a pause and a jump before the change appears.
What is causing this? How do I fix it?
https://jsfiddle.net/6d91cqoq/1/
//pseudo code
EDIT: It also happens going from the first to the last.
EDIT 2:
It's worth noting I took the idea from the Slick.js website: http://kenwheeler.github.io/slick/
On the page with the 'Center Mode' example, it is using transforms to do this exact thing. I cannot for the life of me figure out what is different, other than the target element.
EDIT 3: I did attempt to change my elements to H3 elements, as is in the sample. No change.
The cause for this is that Slick changes the DOM order of the slide elements when switching from "first to last". The transition doesn't kick in when dom elements are removed and added back... You can work around this by playing around with javascript and Slicks beforeChange and afterChange events instead of a pure CSS solution. I have made an example, although the example I made also slightly changes the effect (the center slide won't widen until it is in the center, e.g. afterChange). Maybe with Slicks, next and previous slide parameters you can make it work like your example, didn't have time to investigate it more.
https://jsfiddle.net/6d91cqoq/2/
Changes made to your example:
//Added my own "active" class, so it does not to interfere with slicks active class
.slick-slide.active {
opacity: 1;
transform: scale(1.50);
}
JS
//make current center active after initialization
$('.slick-center').addClass('active');
//before slide change, make all "inactive"
$('.center').on('beforeChange', function(event, slick, index){
$('.slick-slide').removeClass('active');
});
//after change make the center one "active"
$('.center').on('afterChange', function(event, slick, index){
$(slick.$slides[index]).addClass('active');
});
In first excuse me for my bad english, I'm French. I'll do the best ! I'm here today because for the first time i don't find an answer to my problem. Monday i need to show a demo of a website and i start to panic !
So, I have a div with a rotate (45deg). Within this div, I have two div other div in inline-block (with a css rotate (-45deg). On the left i have a slider and on the right text and shortcuts. Today I joined the slider to the left position (I work on joomla). It works well but I have a problem with the slide transition. If I click "next" or "previous", the global div (the main container) becomes blurred for the duration of transition. I did screenshots of the text on the right position (best seen the difference).
Fiddle for example :
http://jsfiddle.net/asakuras/8Pk3S/11/
Pics for example :
Before click and just after the click, during the transition :
http://www.morgann-c.com/tools/js/bug.jpg
Explanations :
I tested many possibility to clean that but no solution at this time. In the script (responsiveslides.js) the transition's are reduction by the opacity. At the line 71 of the script there's the configuration of the opacity :
visible = {"float": "left", "position": "relative", "opacity": 1, "zIndex": 2},
hidden = {"float": "none", "position": "absolute", "opacity": 0, "zIndex": 1, }
If I change the opacity of the hidden class to 0 there's no transition but the bug disappears ! I think this is a problem with the CSS's opacity transition. If I delete the rotate on all the div's the bug also disappears. I tested all the CSS transform but no result ...
I'm working on this bug for 3 days and it's very important for me to find a solution quickly ...
I implore you, if someone has already had this problem i take !
Have a good week end and thank you by advance ...
EDIT //// :
Firefox 30 : "Blur" on click
Chrome 35.0.1916.153 : "Blur" everywhere on page load
IE 11 : No problems, no "blur", everything works perfectly !
First off, you were missing a - in -ms-transform (this is likely the reason why there is no blur in IE - it wasn't using transform)
Secondly, removing -webkit-backface-visibility made it so Chrome only blurs on the transition (I have no idea why you added it given nothing rotates at all).
Thirdly unless you're serving IE8- or something like that you don't need filter for the rotation and -o-transform and -moz-transform are not needed, so remove them
Lastly, the reason why it's blurry is because it's being rendered by the GPU. Though this does always happen when things are generated by the GPU, but I'm thinking that it is simply being overworked by the fact that there are two rotations and in addition to the opacity transition.
Thus, as a solution you have a few options. You can either remove the opacity transition, opting for something like margin-left:-600px (this requires changing the plugin to suit), you could move the header and paragraph outside of <div id="global"> but position it so that it's in the same position as it currently is (making sure none goes outside of the rotated square), or, my personal favorite choose another plugin! The one you're using is quite outdated and there are a lot better free ones just one Google search away
I'm making an app using JQuery Mobile on top of PhoneGap (Cordova). I used Codiqa to come up with a wireframe for my UI. It looks OK so far, but the group of radio buttons I'm going to use to change views with wasn't centred - it was off to the left by about 25px on a WVGA800-sized webkit browser. When scaled to a tablet shape, the group got further and further from the centre of the viewport.
Here's a jsFiddle link to my project with the problem unfixed - http://jsfiddle.net/jaspermogg/sahXy/1/
Here's a jsFiddle link to my project as fixed by me - http://jsfiddle.net/jaspermogg/NvMsK
I came up with a solution using JQuery, but I'm inexperienced and don't know which event to fire on.
When I load the UI in Webkit, it renders the UI pre-script, before refreshing after <1s to a post-script state. This looks lame. I have my script set up to run on $(window).load.
Questions:
What event should I be looking for, and could you show me how to implement that?
Is my script in the right place - should it be inside the page, the way it is, or outside? Or in head even?
It feels really stupid to be doing this with JQ - surely there's a way to do this with CSS?
Thanks in advance for any help offered! Cheers!
I guess I answered my own question in the comments above, so gonna formalise it by accepting my answer.
What I did in the end was -
(1) Set the radio button-containing div to visibility: hidden in the CSS.
(2) Find the widths of each radio button and add them together.
(3) Set the width of the radio button-containing div to the total width.
(4) Chain a change of the visibility property onto (3).
The CSS has to be set up like this -
#viewselector{
margin: 0 auto;
text-align: center;
visibility: hidden;
}
The code to do (1) to (4) is as follows -
$(document).ready(function(){
var idealwidth = 0
$(".ui-radio").each(function(){
idealwidth = idealwidth + $(this).width();
});
$("#viewselector").width(idealwidth).css('visibility','visible');
});
Hope this helps someone!