2012-06-13 11 views
5

मुझे जीडब्ल्यूटी के कस्टमस्क्रॉलपैनल के बारे में पता चला और आप स्क्रॉल बार को कैसे अनुकूलित कर सकते हैं, लेकिन मुझे कोई उदाहरण नहीं मिल रहा है या इसे कैसे सेट अप किया जा सकता है। क्या वहां कोई उदाहरण हैं जो उपयोग में कस्टम स्क्रॉलबार दिखाते हैं?जीडब्ल्यूटी कस्टमस्क्रॉलपैनल उदाहरण

उत्तर

3

इस प्रकार आप मूल स्क्रॉलबार को कस्टमाइज़ करेंगे, हालांकि आप अपनी खुद की स्क्रॉलबार कक्षाएं भी विकसित कर सकते हैं जो वर्टिकलस्क्रॉलबार और क्षैतिज स्क्रॉलबार को लागू करते हैं जो बहुत अधिक अनुकूलन योग्य हैं।

संसाधन (शैली) परिभाषाएँ:

public class ScrollResourcesContainer { 

    public interface ScrollPanelResources extends CustomScrollPanel.Resources 
    { 
     @Override 
     @Source({ "ScrollPanel.css", CustomScrollPanel.Style.DEFAULT_CSS }) 
     CustomScrollPanel.Style customScrollPanelStyle(); 
    } 

    public interface HorizontalResources extends NativeHorizontalScrollbar.Resources 
    { 
     @Override 
     @Source({ "HorizontalScrollbar.css", NativeHorizontalScrollbar.StyleTransparant.DEFAULT_CSS }) 
     NativeHorizontalScrollbar.Style nativeHorizontalScrollbarStyle(); 
    } 

    public interface VerticalResources extends NativeVerticalScrollbar.Resources 
    { 
     @Override 
     @Source({ "VerticalScrollbar.css", NativeVerticalScrollbar.StyleTransparant.DEFAULT_CSS }) 
     NativeVerticalScrollbar.Style nativeVerticalScrollbarStyle(); 
    } 
} 

प्रयोग के माध्यम से CustomScrollPanel:

CustomScrollPanel csp = new CustomScrollPanel((ScrollResourcesContainer.ScrollPanelResources) GWT.create(ScrollResourcesContainer.ScrollPanelResources.class)); 
    csp.setHorizontalScrollbar(new NativeHorizontalScrollbar((HorizontalResources) GWT.create(HorizontalResources.class)), 
    AbstractNativeScrollbar.getNativeScrollbarHeight()); 
    csp.setVerticalScrollbar(new NativeVerticalScrollbar((VerticalResources) GWT.create(VerticalResources.class)), 
    AbstractNativeScrollbar.getNativeScrollbarWidth()); 
+0

क्या सीएसएस फाइलें अनुकूलन की अनुमति देती हैं? क्या आप VerticalScrollbar.css के लिए नमूना प्रदान कर सकते हैं? – sworded

+0

हां वे हैं, लेकिन आप ऐसा नहीं कर सकते हैं क्योंकि वे मूल स्क्रॉल बार का उपयोग कर रहे हैं, यदि आप बहुत अनुकूलन चाहते हैं तो आप पूरी तरह से कस्टम डीओएम कार्यान्वयन बनाना चाहते हैं। उदाहरण के लिए आपको gwt-user.jar को अनजिप करके जीडब्ल्यूटी स्रोत देखना चाहिए और कॉम \ google \ gwt \ user \ client \ ui में AbstractNativeScrollbar.java और NativeVerticalScrollbar.java NativeVerticalScrollbar.ui.xml और NativeVerticalScrollbarTransparent.css पर देख रहे हैं। – LINEMAN78

2

gwt में खड़ी स्क्रॉलबार के लिए चिकना स्क्रॉलबार पाने के लिए आपको VerticalScrollbar में कोड निम्नलिखित जोड़ने की जरूरत है। सीएसएस। जो आईई के लिए जीमेल की तरह काम नहीं करेगा।

/* Turn on a 16x16 scrollbar */ 
::-webkit-scrollbar { 
    width: 16px; 
    height: 16px; 
} 

/* Turn on single button up on top, and down on bottom */ 
::-webkit-scrollbar-button:start:decrement, 
::-webkit-scrollbar-button:end:increment { 
    display: block; 
} 

/* Turn off the down area up on top, and up area on bottom */ 
::-webkit-scrollbar-button:vertical:start:increment, 
::-webkit-scrollbar-button:vertical:end:decrement { 
    display: none; 
} 

/* Place The scroll down button at the bottom */ 
::-webkit-scrollbar-button:end:increment { 
    background-image: url(images/scroll_cntrl_dwn.png); 
} 

/* Place The scroll up button at the up */ 
::-webkit-scrollbar-button:start:decrement { 
    background-image: url(images/scroll_cntrl_up.png); 
} 

/* Top area above thumb and below up button */ 
::-webkit-scrollbar-track-piece:vertical:start { 
    background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png); 
    background-repeat: no-repeat, repeat-y; 
} 

/* Bottom area below thumb and down button */ 
::-webkit-scrollbar-track-piece:vertical:end { 
    background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png); 
    background-repeat: no-repeat, repeat-y; 
    background-position: bottom left, 0 0; 
} 

/* The thumb itself */ 
::-webkit-scrollbar-thumb:vertical { 
    height: 56px; 
    -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch; 
    border-width: 8 0 8 0; 
} 
+0

इसी प्रकार आप क्षैतिज स्क्रॉलबार के लिए भी कर सकते हैं। अधिक जानकारी के लिए कृपया निम्न लिंक देखें। http://almaer.com/blog/creating-custom-scrollbars-with-css-how-css-isnt-great-for-every-task – Saritha

+0

वर्टिकलस्क्रॉलबार.css के लिए धन्यवाद, इससे वास्तव में बहुत मदद मिली। क्या आपके पास क्षैतिज Scrollbar.css नमूना है? – MattWeiler

0

यदि कोई भी लंबवत/क्षैतिज दोनों के लिए सीएसएस रखने में रूचि रखता है, तो मैं यही उपयोग कर रहा हूं।

HorizontalScrollbar.css

/* *********** 
* SCROLLBAR * 
* ***********/ 
.nativeHorizontalScrollbar::-webkit-scrollbar 
{ 
    width: 10px; 
    height: 10px; 
} 

/* ************* 
* BUTTON AREA * 
* *************/ 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:horizontal 
{ 
    background-color: transparent; 
} 

/* Increment scroll left/right button. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:start:decrement, 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:end:increment 
{ 
    display: block; 

    width: 10px; 
    height: 8px; 

    background-repeat: no-repeat; 
    background-size: 10px 8px; 
} 

/* Increment scroll left button. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:start:decrement 
{ 
    background-image: url('images/scroll-left.png'); 
} 

/* Increment scroll right button. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:end:increment 
{ 
    background-image: url('images/scroll-right.png'); 
} 

/* Jump left/right buttons. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:horizontal:start:increment, 
.nativeHorizontalScrollbar::-webkit-scrollbar-button:horizontal:end:decrement 
{ 
    display: none; 
} 

/* ****************** 
* TRACKING SECTION * 
* ******************/ 
.nativeHorizontalScrollbar::-webkit-scrollbar-track:horizontal 
{ 
    background-color: transparent; 
} 

/* Area between the thumb and the left button. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-track-piece:horizontal:start 
{ 

} 

/* Area between the thumb and and right button. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-track-piece:horizontal:end 
{ 

} 

/* 
* The tracking area. 
* This is the area that the thumb travels along. 
*/ 
.nativeHorizontalScrollbar::-webkit-scrollbar-track-piece 
{ 
    background-color: rgba(255, 255, 255, 0.1); 
} 

/* The tracking piece. */ 
.nativeHorizontalScrollbar::-webkit-scrollbar-thumb:horizontal 
{ 
    height: 15px; 

    background-color: rgba(255, 255, 255, 0.75); 

    border: none; 
    -webkit-border-top-left-radius: 6px; 
    -webkit-border-top-right-radius: 6px; 
    -webkit-border-bottom-left-radius: 6px; 
    -webkit-border-bottom-right-radius: 6px; 
    -moz-border-radius-topleft: 6px; 
    -moz-border-radius-topright: 6px; 
    -moz-border-radius-bottomleft: 6px; 
    -moz-border-radius-bottomright: 6px; 
    border-top-left-radius: 6px; 
    border-top-right-radius: 6px; 
    border-bottom-left-radius: 6px; 
    border-bottom-right-radius: 6px; 
} 

/* ******** 
* CORNER * 
* ********/ 
.nativeHorizontalScrollbar::-webkit-scrollbar-corner:horizontal 
{ 
    background-color: transparent; 
} 

/* ********* 
* RESIZER * 
* *********/ 
.nativeHorizontalScrollbar::-webkit-scrollbar-resizer:horizontal 
{ 
    background-color: transparent; 
} 

VerticalScrollbar.css /* *********** * स्क्रॉलबार * * ********* **/

.nativeVerticalScrollbar::-webkit-scrollbar 
{ 
    width: 10px; 
    height: 10px; 
} 

/* ************* 
* BUTTON AREA * 
* *************/ 
.nativeVerticalScrollbar::-webkit-scrollbar-button:vertical 
{ 
    background-color: transparent; 
} 

/* Increment scroll up/down buttons. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-button:start:decrement, 
.nativeVerticalScrollbar::-webkit-scrollbar-button:end:increment 
{ 
    display: block; 

    width: 10px; 
    height: 8px; 

    background-repeat: no-repeat; 
    background-size: 10px 8px; 
} 

/* Increment scroll up button. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-button:start:decrement 
{ 
    background-image: url('images/scroll-up.png'); 
} 

/* Increment scroll down button. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-button:end:increment 
{ 
    background-image: url('images/scroll-down.png'); 
} 

/* Jump up/down buttons. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-button:vertical:start:increment, 
.nativeVerticalScrollbar::-webkit-scrollbar-button:vertical:end:decrement 
{ 
    display: none; 
} 

/* ****************** 
* TRACKING SECTION * 
* ******************/ 
.nativeVerticalScrollbar::-webkit-scrollbar-track:vertical 
{ 
    background-color: transparent; 
} 

/* Area between the thumb and the up button. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-track-piece:vertical:start 
{ 

} 

/* Area between the thumb and and down button. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-track-piece:vertical:end 
{ 

} 

/* 
* The tracking area. 
* This is the area that the thumb travels along. 
*/ 
.nativeVerticalScrollbar::-webkit-scrollbar-track-piece 
{ 
    background-color: rgba(255, 255, 255, 0.1); 
} 

/* The tracking piece. */ 
.nativeVerticalScrollbar::-webkit-scrollbar-thumb:vertical 
{ 
    height: 15px; 

    background-color: rgba(255, 255, 255, 0.75); 

    border: none; 
    -webkit-border-top-left-radius: 6px; 
    -webkit-border-top-right-radius: 6px; 
    -webkit-border-bottom-left-radius: 6px; 
    -webkit-border-bottom-right-radius: 6px; 
    -moz-border-radius-topleft: 6px; 
    -moz-border-radius-topright: 6px; 
    -moz-border-radius-bottomleft: 6px; 
    -moz-border-radius-bottomright: 6px; 
    border-top-left-radius: 6px; 
    border-top-right-radius: 6px; 
    border-bottom-left-radius: 6px; 
    border-bottom-right-radius: 6px; 
} 

/* ******** 
* CORNER * 
* ********/ 
.nativeVerticalScrollbar::-webkit-scrollbar-corner:vertical 
{ 
    background-color: transparent; 
} 

/* ********* 
* RESIZER * 
* *********/ 
.nativeVerticalScrollbar::-webkit-scrollbar-resizer:vertical 
{ 
    background-color: transparent; 
}