Full Web Page Easing with jquery - easing

I've been trying to understand how to implement a full page ease... How do you call or tell the script the order of tags I want to ease into the page? Do I need to use a body load function?
Many thanks.
Erik

Here is a tutorial for fading in and out when you change pages: http://www.onextrapixel.com/2010/02/23/how-to-use-jquery-to-make-slick-page-transitions/
If you want to have the pages "bounce" in and out, you can setup your website to be contained in div tags on the same page and simply "ease" them in and out like a slideshow.
CSS --
.panel{
float: left;
position: absolute;
width: 100%;
height: 100%;
display: inline-block;
}
HTML --
<div id='div1' class='panel'>Page 1</div>
<div id='div2' class='panel'>Page 2</div>
<div id='div3' class='panel'>Page 3</div>
<div id='div4' class='panel'>Page 4</div>
<div id='div5' class='panel'>Page 5</div>
JavaScript --
$(document).ready(function () {
var left = 0;
var width = $(window).width();
var easing_type = 'easeOutBack';
$(window).resize(function() {
initialize_all();
});
initialize_all();
function initialize_all() {
left = 0;
width = $(window).width();
$("#div1").css({
left: 0 + "px"
});
$("#div2").css({
left: width + "px"
});
$("#div3").css({
left: 2 * width + "px"
});
$("#div4").css({
left: 3 * width + "px"
});
$("#div5").css({
left: 4 * width + "px"
});
}
function move_forward() {
left -= width;
if (left 0) {
left = -4 * width;
}
$("#div1").animate({
left: left + "px"
}, transition_time, easing_type);
$("#div2").animate({
left: left + width + "px"
}, transition_time, easing_type);
$("#div3").animate({
left: left +2 * width + "px"
}, transition_time, easing_type);
$("#div4").animate({
left: left +3 * width + "px"
}, transition_time, easing_type);
$("#div5").animate({
left: left +4 * width + "px"
}, transition_time, easing_type);
}
});
This was a simple attempt at a slideshow I had tried, you will need to include the jquery easing plugin but then you can choose from like 30 different easing types.

Related

How to make two divs resizable only by width in vuejs

I want to create two divs and make them re-sizable with respect to each others width in VueJS
$(function() {
var A = parseInt($('#A').width(), 10),
B = parseInt($('#B').width(), 10),
Z = parseInt($('#Z').width(), 10),
minw = parseInt((A + B + Z) * 10 / 100, 10),
offset = $('#container').offset(),
splitter = function(event, ui) {
var aw = parseInt(ui.position.left),
bw = A + B - aw;
//set widths and information...
$('#A').css({
width: aw
}).children().text(aw);
$('#B').css({
width: bw
}).children().text(bw);
};
$('#Z').draggable({
axis: 'x',
containment: [
offset.left + minw,
offset.top,
offset.left + A + B - minw,
offset.top + $('#container').height()
],
drag: splitter
});
//information...
$('#width').text(A + B + Z);
$('#A div').text(A);
$('#B div').text(B);
});
#container {
width: 90%;
height: 100px;
margin: 0 auto;
position: relative;
}
#A,
#B,
#Z {
position: absolute;
top: 0;
height: 100%;
}
#A {
left: 0;
width: 39%;
background-color: #ccffcc;
}
#B {
right: 0;
width: 59%;
background-color: #ccccff;
}
#Z {
left: 39%;
width: 2%;
background-color: #cc0000;
cursor: move;
}
#A div,
#B div {
position: absolute;
top: 40%;
left: 0;
width: 100%;
text-align: center;
}
#info {
text-align: center;
line-height: 2em;
}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div id='info'>container width : <span id='width'></span></div>
<div id='container'>
<div id='A'>
<div>a</div>
</div>
<div id='B'>
<div>b</div>
</div>
<div id='Z'></div>
</div>
You are mixing Vue with jQuery, so when your jQuery code runs the Vue app might not be ready.
A solution could be to wrap the draggable library in a <Draggable> component and use refs to access the DOM nodes from the mounted hook in the Vue component.

Vue I want an image to follow the mouse

I am having trouble with a Vue component https://jsfiddle.net/shawnswebsites/fep1p02c/20/. I have a div in the component and when the user's mouse enters the div I want an image to be shown and I want the image to follow the mouse.
new Vue({
el: '#app',
data: {
showImage: false,
page: {
left : 0,
top: 0
},
},
methods: {
onMouseMove(e) {
console.log('page x: ' + this.page.left);
this.page.left = e.pageX;
this.page.top = e.pageY;
}
}
})
.container {
height: 400px;
width: 400px;
border: 1px solid #FFF;
background-color: grey;
margin: 40px;
}
.image {
position: absolute;
z-index: 1000;
overflow:hidden;
}
<script src="https://unpkg.com/vue"></script>
<div id="app">
<div class="container"
#mouseenter="showImage = true"
#mousemove.self="onMouseMove($event)"
#mouseleave="showImage = false">
</div>
<img v-show="showImage" class="image" src="http://via.placeholder.com/350x150" :style="{ left: page.left + 'px', top: page.top + 'px' }">
</div>
I use a #mouseenter to show the image and #mouseleave to hide the image. However, #mouseleave is still being called as I scroll over the div, which is causing the image to blink on and off. Can any help?
As said Oxcarga in the comment below you need to add pointer-events: none; to your image style:
.image {
position: absolute;
z-index: 1000;
overflow:hidden;
pointer-events: none;
}

Bootstrap 3 - carousel with page numbers

I am wondering how to show page numbers with Bootstrap Carousel. Bootstrap has carousel indicators (dot points):
Is it possible to change the indicator to something like "Page 1/3"?
I have tried adding the number to bootstrap caption and moving it to the left side:
However, whenever I clicked next, the number didn't stay at its place. Any ideas how to make this better?
Thanks!
Found a working solution:
var total = $('.item').length;
var currentIndex = $('div.active').index() + 1;
$('#slidetext').html(currentIndex + '/' + total);
// This triggers after each slide change
$('.carousel').on('slid.bs.carousel', function () {
currentIndex = $('div.active').index() + 1;
// Now display this wherever you want
var text = currentIndex + '/' + total;
$('#slidetext').html(text);
});
http://jsfiddle.net/Lf9krnsm/
carousel.on('slide.bs.carousel', function (event) {
var active = $(event.target).find('.carousel-inner > .item.active');
var from = active.index();
var next = $(event.relatedTarget);
var to = next.index();
var direction = event.direction;
});
HTML5:
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#client" data-slide-to="0" class="active">1</li>
<li data-target="#client" data-slide-to="1">2</li>
<li data-target="#client" data-slide-to="2">3</li>
</ol>
SASS:
.carousel-indicators{
bottom: -15px;
left: 80%;
li{
width: 17px;
height: 17px;
margin: 3px;
text-indent: 0;
background-color: $wcolor;
border: 1px solid $bcolor;
border-radius: 0;
line-height: 13px;
}
.active {
width: 17px;
height: 17px;
background-color: #ddd;
}
}

css resize: How to resize a dynamic growing div after max height is active

I want to dynamically add items to the list. the list's height should be as high as the items are. but at a certain point, it's 300px, the ul should stop "growing" … i did this with "max-height". so far so good. NOW that i have a scrollbar I want to add a resize functionality, so that the user can decide if it's bigger than max-height or not.
The problem is that it can't resize higher than max-height. Does anybody know how to do this? the best way?
html:
click to add
<ul>
<li>start</li>
</ul>
css:
ul {
background: #f2f2f2;
overflow: auto;
height: auto;
max-height: 300px;
resize: vertical;
}
js/jquery:
$('a').on('click', function (e) {
e.preventDefault();
$('ul').append('<li>item</li>');
});
here is the same on fiddle to see it in action: http://jsfiddle.net/ZwrzX/
thx in advance!
Working fiddle: http://jsfiddle.net/ZwrzX/4/
When the UL height reaches 290px, a link appears besides the add item link and the user can click on it to add 25px to the max-height of the UL, if the user clicks it 2 times, 50px (2 x 25px) is added to the max-height of the UL.
HTML
click to add item
Add 25px to UL Max height
<ul>
<li>start</li>
</ul>
JavaScript
$('#addItem').on('click', function (e) {
e.preventDefault();
$('ul').append('<li>item</li>');
if ($('ul').height() > 290) {
$('#addHeight').css('visibility', 'visible');
}
});
$('#addHeight').on('click', function() {
var currenULtHeight = $('ul').height();
$('ul').css('max-height', currenULtHeight + 25 + 'px')
});
CSS
ul {
background: #f2f2f2;
overflow: auto;
height: auto;
max-height: 300px;
resize: vertical;
}
#addHeight {
visibility: hidden;
}
ok. i tried again on my own and came to the following:
var max_h = $('ul').css('max-height').replace('px', '');
function check_height() {
var sum = 0;
$('li').each(function () {
sum += $(this).height();
});
if (sum >= max_h) $('ul').css({ 'height': max_h, 'max-height': sum });
else $('ul').css({ 'height': 'auto', 'max-height': max_h });
}
$('#addItem').on('click', function (e) {
e.preventDefault();
$('ul').append('<li>item</li>');
check_height();
});
$('#removeItem').on('click', function (e) {
e.preventDefault();
$('li').last().remove();
check_height();
});
fiddle: http://jsfiddle.net/ZwrzX/6/
I was asking if there is a cleaner solution. or a solution with less js?
any further ideas?

Query node and set style with Dojo

I have the following node structure in my HTML:
<div id="widget1" class="dojoxFloatingPane dijitContentPane dojoxFloatingPaneFg" title="" role="group" style="position: absolute; top: 82px; left: 231px; width: 984px; height: 276px; z-index: 102;" widgetid="widget1">
<div class="dojoxFloatingPaneTitle" dojoattachpoint="focusNode" role="button" tabindex="0">
<div class="dojoxFloatingPaneCanvas" dojoattachpoint="canvas" style="left: 0px; top: 0px; width: 984px; height: 249px;">
<iframe class="dijitBackgroundIframe" src="javascript:""" role="presentation" style="opacity: 0.1; width: 100%; height: 100%;" tabindex="-1">
I'm trying to set the size of this FloatingPane with Dojo with the following peace of code. First I read in the nodes, the widget1 node and then I look for the dojoxFloatingPaneTitle class and store these nodes in variables. Then I read the cookie and it successfully sets the style on the paneNode.
var paneNode = dom.byId("widget1");
var canvasNode = query(".dojoxFloatingPaneCanvas", paneNode);
function(){
var wid1saved = dojo.fromJson(cookie("widget1"));
domStyle.set(paneNode, {
left: wid1saved.x + "pt",
top: wid1saved.y + "pt",
width: wid1saved.w + "px",
height: wid1saved.h + "px",
position: "absolute"
});
domStyle.set(canvasNode, {
width: wid1saved.w + "px",
height: wid1saved.h + "px",
backgroundColor: "black"
});
}
It does set the size of the outer node (paneNode) but the canvas inside (canvasNode) is unchanged. In the debugger I can see that the query does find the proper node.
Any ideas why the canvasNode style is not set?
Many thanks
dojo.query usually returns an array of the objects found.
Have you tried:
var canvasNode = query(".dojoxFloatingPaneCanvas", paneNode)[0];