PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Frage: Klassen, Funktionen und Mouseover


BigRob
2009-10-28, 23:26:55
Hi.

1.

Ich möchte eine Navileiste basteln und für alle Menüpunkte (Grafiken) folgende Funktion anwenden:

function fadeIn() {
Navi.style.filter="Alpha(opacity="+oc+", finishopacity=0, style=2)"
if(oc!=100) setTimeout('oc++;fadeIn()',20);
else setTimeout('fadeOut()',5000);
}

das Geht für ein einzelnes element (Navi) auch ganz gut.

Aber ich würde die Funktion gerne auf alle Menüpunkte anwenden.

Wie kann ich diese Funktion für Klassen deklarieren?

2. Gibt es eine Möglichkeit einen Mouseover-effekt so anzuwenden, dass die änderung (Bildwechsel) solange gültig ist bis ein neuer Menüpunkt angewählt wird?

Ich hoffe mir kann jemand von euch helfen.

darph
2009-10-29, 12:22:12
Du möchtest dir jQuery (http://jquery.com/) anschauen. Das ist für das, was du machen willst, geradezu prädestiniert.

Beispiel:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Simple plugin demo: Keep effect active until hovered over another element</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<!-- content should not be text/html -->
<!-- fix the FOUC -->
<script type="text/javascript"> </script>

<style type="text/css" media="screen">
.hoverstuff {
width: 50px;
height: 50px;
float: left;
border: 5px dotted yellow;
background-color: silver;
}
</style>

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script type='text/javascript' src='jquery.testlib.js'></script>

<script type="text/javascript">
$(document).ready(function() {
// apply effect to all elements that have the class ".hoverstuff"
// let's set the default opacity to 0.5 and keep the duration at default
$(".hoverstuff").hoverstuff({visibility: 0.5})
});
</script>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body>
<h1>Simple plugin demo: Keep effect active until hovered over another element</h1>
<div class="hoverstuff">a</div>
<div class="hoverstuff">b</div>
<div class="hoverstuff">c</div>
<div class="hoverstuff">d</div>
<div class="hoverstuff">e</div>
<div class="hoverstuff">f</div>
</body>
</html>





//file jquery.testlib.js
(function($){
$.fn.hoverstuff = function(options) {
//these are our defaults
var defaults = {
visibility: 0.2,
duration: 1000
};

// apply defaults where options are not set.
var options = $.extend(defaults, options);

// the set of elements that this plugin is applied to
var elems = this;

// for each element in the set
return elems.each(function() {

// apply standard opacity
$(this).css("opacity", options.visibility);

// bind mouseOver Event
$(this).mouseover(function() {

// if we mouse over, we mark this element as active
// then make it fully visible
$(this).addClass("active").stop().animate({
opacity: 1
}, options.duration);

// all other elements in the set,
// that are currently not marked as active and hence
// not hovered, are returned to default state.
elems.each(function() {
if (!$(this).hasClass("active")) {
// only those that are not active right now
$(this).stop().animate({
// reset to default
opacity: options.visibility
}, options.duration);
}
});
});

// bind mouseOut event
$(this).mouseout(function() {
// when we mouse out, we remove the class
// so that it can be hidden when we hover
// over another element of the set
$(this).removeClass("active");
});
});
};
})(jQuery);

BigRob
2009-11-05, 09:43:36
Danke soweit.
Werde es mal probieren.

Andere frage: Ich mal ein Java-Script gesehen, was dass aktuelle browser fenster über den bildschirm wandern lässt - alo eine scherzanimation.

leider finde ich das script nicht mehr. kennt es evtl von euch jemand - wäre toll.

alkorithmus
2009-11-05, 15:24:51
Du möchtest dir jQuery (http://jquery.com/) anschauen.

Stark! Danke dir. Habe es mir mal zu Gemüt geführt. Kann man gebrauchen.

The_Invisible
2009-11-05, 16:58:09
Danke soweit.
Werde es mal probieren.

Andere frage: Ich mal ein Java-Script gesehen, was dass aktuelle browser fenster über den bildschirm wandern lässt - alo eine scherzanimation.

leider finde ich das script nicht mehr. kennt es evtl von euch jemand - wäre toll.

sorry, das ist nicht lustig sondern nervig, wird bei mir als erster im browser deaktivert.

damit dieser post aber nicht ganz unnötig war: http://www.google.at/search?hl=de&source=hp&q=javascript+move+browser+window&meta=&btnG=Google-Suche

mfg

Roi Danton
2009-11-08, 19:20:09
Kann man gebrauchen.Oder anders ausgedrückt: Ohne gehts inzwischen nicht mehr. ;)

alkorithmus
2009-11-13, 20:21:46
Oder anders ausgedrückt: Ohne gehts inzwischen nicht mehr. ;)

Für ein verstaubten Printer wie mich ist das Neuland. ;(

darph
2009-11-14, 18:32:32
Für ein verstaubten Printer wie mich ist das Neuland. ;(
Sie müssen ja nicht alles wissen. Sie müssen nur wissen, wer Ihnen das zu annehmbaren Preisen macht. ;)