Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to resize and fontresize on window, not document. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/placeholder_polyfill.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
var input = $(this),
text = input.attr('placeholder'),
id = input.attr('id'),
label,placeholder,titleNeeded,polyfilled;
label,placeholder,titleNeeded,polyfilled,timerId;

function onFocusIn() {
if(!o.options.hideOnFocus && window.requestAnimationFrame){
Expand Down Expand Up @@ -152,8 +152,11 @@
showPlaceholderIfEmpty(input,o.options);

// reformat on window resize and optional reformat on font resize - requires: http://www.tomdeater.com/jquery/onfontresize/
$(document).bind("fontresize resize", function(){
positionPlaceholder(placeholder,input);
$(window).bind("fontresize resize", function(){
if (timerId) clearTimeout(timerId);
timerId = setTimeout(function() {
positionPlaceholder(placeholder,input);
}, 500);
});

// optional reformat when a textarea is being resized - requires http://benalman.com/projects/jquery-resize-plugin/
Expand Down