Last active
January 12, 2022 08:43
-
-
Save micah1701/c641c40a18e28b7dc064ed3c3a37f6c4 to your computer and use it in GitHub Desktop.
Extends bulma.io CSS framework with a short-lived notification message that slides up from the bottom of the screen. Useful for showing user that a change has occurred on the page. Requires jQuery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* display a quick notification box that slides up from the bottom for a few seconds | |
*/ | |
function quickNotice(message,cssClass,timeOnScreen) | |
{ | |
cssClass = (cssClass) ? cssClass : 'is-success'; | |
timeOnScreen = (timeOnScreen) ? timeOnScreen : 3000; | |
var html = '<div id="quickNotice" style="position: absolute; z-index: 100; width: 100%" class="notification has-text-centered has-text-weight-semibold '+cssClass+'">'; | |
html+= message; | |
html+= '</div>'; | |
$('body').append(html); | |
var notice = $("#quickNotice"), | |
startPosition = (notice.innerHeight()) * -1; | |
notice.css({'bottom':startPosition+'px'}); | |
notice.animate({bottom:0},300); | |
setTimeout(function(){ | |
notice.animate({bottom:startPosition+'px'},500,function(){ | |
notice.remove(); | |
}); | |
},timeOnScreen); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment