Today i’ve got an idea to make a request section. Maybe you need some plugin or tutorial that you can’t find on google, but you really need it? Post a comment and I will try to help you. Request for a plugin, tutorial, tip or other similar task. Try to write as much information as you can about your request. I promise that all of you will get my reply.
jquery sticky box
Today I am going to teach you how to make a sticky floating box on the page. Did you saw any webpage that got a cool floating sticky toolbar/menu or box when you scroll the page. You think yes, I could use a CSS property position: fixed . No, it’s not about just fixed position box that moves when you scroll, it is about when you scroll the page, but it is not moving only on one condition when it is going to hide. Here is an example.
And here is a full code:
var stickyBox = $(".sticky-box");
var stickyBoxPosition = stickyBox.offset().top;
stickyBox.css('position', 'relative');
$(window).scroll(function(){
if(stickyBoxPosition < $(window).scrollTop()) {
stickyBox.stop().animate({
"top": ($(window).scrollTop() - stickyBoxPosition) + "px"
}, "fast" );
} else {
stickyBox.css('top', 0);
}
});
Comments:
var stickyBox = $(".sticky-box");
.sticky-box is your div or other element class that you want to stick. Where you add this class on any of element it will float.
var stickyBoxPosition = stickyBox.offset().top;
Get element position form the top
stickyBox.css('position', 'relative');
give it a relative position that it could float on the top of content
$(window).scroll(function(){
all logic goes here when you scroll the window
if(stickyBoxPosition < $(window).scrollTop()) {
now check if box is going to hide when you scroll
stickyBox.stop().animate({ "top": ($(window).scrollTop() - stickyBoxPosition) + "px"}, "fast" );
this is box scrolling animation if the box is going to hide. It will allways stick at the top of the window view
} else {
stickyBox.css('top', 0);
and if the box is not going to hide, then leave it alone
Conclusion
So it is so simple. I am not good teacher, but I hope you will understand
All this script goes to document ready $(function(){ …. script here … }); and add to the elements you want a class sticky-box . Try it yourself!
Netbeans utf-8
Today I started to use Netbeans for PHP development. Everything seems ok and works faster than zend studio, BUT! When I tried to open a php file I’ve noticed that there was no utf8 support. I was looking all over the options and had to head bang the wall till I got an idea to check the best source for all questions. Google! . Voila I’ve found an answer in a second search result. It seems that there are no such option to change encoding. You need to edit neatbeans config file. So if you got the same problem you need to go to netbeans -> etc and open netbeans.conf file. There on the line netbeans_default_options add -J-Dfile.encoding=UTF-8 and all your files will open in utf8 by default. If you get error when try to save file that this file is opened in other programa bla bla bla and you can’t save, then run text editor as administrator. Save file, open netbeans and file that should be utf8. Yay it works!
Jquery vertical news scroller
One day i’ve got an assigment to make scrollable news. I was searching internet for simple jquery plugin to fit my needs. But with no luck I couldn’t find nothing that looks how it should. So my decision was to make a simple jquery plugin for news ticker that I could use later. And here it is. I want to share with you my first jquery plugin. It is easy to use as $(‘.myclass’).vTicker(); and you will see the magic
It is scrolling automaticaly and it has an infinite loop. You can find it by clicking here .
Check out example and download if it is something that you need. I’ve got a lot of good reviews, so I am happy that I can share a bit of my work with others.
Hello world!
Hello world! This is another bit on the world wide web.
First of all I want to introduce myself. I am Tadas Juozapaitis, 22 years old. I live in a little country called Lithuania that is found in europe. I work as a PHP web developer, so this blog will be mainly used for tips/tricks/projects that fits in web development category. I love Jquery framework and I don’t imagine my work without this very powerfull javascript framework. It helps so much! I try to use latest technologies to enchant my works. About web design… I always have an idea how the design should look (and it would look very cool), but I can’t paint it. Painting is not my best side.
So to sum up, this blog is about web development and the main idea is to use this blog for myself. I will put here all my project and maybe some code snippets that later if I need something from the past, I will come here and will be able to find it fast. Maybe you also will find something useful in here. Have a nice day!