Jssor Slider - How to disable scaling? - scaling

I just discovered Jssor Slider.
It is fantastic.
Quick question.
How do you disable the built-in scaling?
Thanks,
D

Open any template in the package, you may see the following code.
//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$ScaleWidth(Math.min(parentWidth, 600));
else
window.setTimeout(ScaleSlider, 30);
}
ScaleSlider();
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end
It is the code to scale the slider while window resizes. If you don't need this feature, remove it then.

Jssor has an option FillMode, set to 5. I used and works fine to the main image nor to thumbnail.
/* Main Slider Section */
var options_slider1 = {
$AutoPlay : false, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
$PauseOnHover : 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1
$DragOrientation : 3, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
$ArrowKeyNavigation : true, //[Optional] Allows keyboard (arrow key) navigation or not, default value is false
$SlideDuration : 600, //Specifies default duration (swipe) for slide in milliseconds
$SlideshowOptions : {//[Optional] Options to specify and enable slideshow or not
$Class : $JssorSlideshowRunner$, //[Required] Class to create instance of transitions to play slideshow
$TransitionsOrder : 1, //[Optional] The way to choose transition to play slide, 1 Sequence, 0 Random
$ShowLink : true //[Optional] Whether to bring slide link on top of the slider when slideshow is running, default value is false
},
$ArrowNavigatorOptions : {//[Optional] Options to specify and enable arrow navigator or not
$Class : $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance
$ChanceToShow : 1, //[Required] 0 Never, 1 Mouse Over, 2 Always
$AutoCenter : 2, //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
$Steps : 1 //[Optional] Steps to go for each navigation request, default value is 1
},
$ThumbnailNavigatorOptions : {//[Optional] Options to specify and enable thumbnail navigator or not
$Class : $JssorThumbnailNavigator$, //[Required] Class to create thumbnail navigator instance
$ChanceToShow : 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
$ActionMode : 1, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
$Lanes : 1, //[Optional] Specify lanes to arrange thumbnails, default value is 1
$SpacingX : 14, //[Optional] Horizontal space between each thumbnail in pixel, default value is 0
$SpacingY : 12, //[Optional] Vertical space between each thumbnail in pixel, default value is 0
$Cols: 6, //[Optional] Number of pieces to display, default value is 1
$Align: 156, //[Optional] The offset position to park thumbnail
$Orientation : 2 //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1
},
$FillMode: 5, // The way to fill image in slide, 0: stretch, 1: contain (keep aspect ratio and put all inside slide), 2: cover (keep aspect ratio and cover whole slide), 4: actual size, 5: contain for large image and actual size for small image, default value is 0
};
var jssor_slider1 = new $JssorSlider$("slider1_container", options_slider1);
//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
$('#listing_template_wraper').width($(window).width());
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 960), 300));
else
window.setTimeout(ScaleSlider, 30);
}
ScaleSlider();
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
/* End Main Slider Section */

Related

Change polygon size on window resize

In my QML application I am drawing a triangle manually using "Canvas" object. The problem is I cannot figure out how to change the drawn object size each time I resize the main window.
Preferably, it would be convenient If I could simply redraw the triangle each time a window resize occurs. But I don't know how could this be done in QML. In bare QT, I guess I would subscribe to window size changed signal. What is the proper way of doing this in QML?
Edit: The program is described here: Change polygon color dynamically
In my main window there is a rectangle called rectMain. It is always the same size as the window. Then inside that rectangle there is another one, called rectTemp. In that rectangle I draw the canvas.
Edit 2: So far I have figure out how to react manually on window size changes:
property int lastWindowWidth: 0
property int lastWindowHeight: 0
function windowSizeChanged()
{
if ((lastWindowWidth == width) && (lastWindowHeight == height))
return;
console.log("New height: ", height, " New width: ", width);
lastWindowWidth = width
lastWindowHeight = height
}
onHeightChanged: windowSizeChanged();
onWidthChanged: windowSizeChanged();

How to adjust size of widgets like frame,label,text inside a window with resizing of the window in tcl tk GUI

I am new in tcl\tk and I am developing a UI using it. The UI window has a frame that has dynamic number of labels and text widgets filled according to the number of columns in a table. There is an entry widget for each column, data typed in it by user populates each column in the table.
However the problem I am facing is that , I cannot find a way to make the size and position of the widgets inside the frame in the window adjust themselves according to the size of the window. That is if the user enlarges the window by dragging and enlarging its size the widgets inside the window should also increase in size and adjust their positions according to the window size. Vice versa if the window size id decreased. Something like bootstrap in HTML, CSS.
Can anyone please give me any idea??
Any help is greatly appreciated. Thanks!
You need to read the documentation on the grid and pack commands.
With pack, the -fill and -expand options will help you adjust how the
widget reacts to resizing.
Examples:
pack .widget -fill both -expand true
pack .widget -fill x -expand true -anchor s
With grid, the -sticky option and columnconfigure and rowconfigure sub-commands will be useful to you.
Examples:
grid .widget -sticky ew
grid columnconfigure . 0 -weight 1
In some cases there may be special actions you will need to take upon a resize. In this case, the bind command will be useful. You can bind to a <Configure> event and adjust widget sizes or take other actions as necessary.
Edit:
The grid columnconfigure applies to a column of a containing frame. So you don't have to run it for each widget. In the example above, .widget is contained in the . frame and the . frame's column is configured.
# in this example, the entry fields will adjust their width when
# the window is resized.
package require Tk
grid columnconfigure . 1 -weight 1
foreach {val} {1 2 3 4 5 6 7} {
ttk::label .lab$val -text "Label $val:"
ttk::entry .entry$val -textvariable mydata($val)
grid .lab$val .entry$val -in . -sticky w
# change the configuration for .entry$val only...
grid configure .entry$val -sticky ew
}
proc doresize { win } {
puts "Win $win now has width: [winfo width $win]"
}
bind . <Configure> [list ::doresize %W]
Note that with this example, the bind also applies to all of the children of . as . is a top-level window. If you are only interested in changes to ., you can change the resize procedure:
proc doresize { win } {
if { $win eq "." } {
puts "Win $win now has width: [winfo width $win]"
}
}
If the bind is applied to a frame or widget that is not a top-level window, the events are only received for that frame or widget.
Also note that you will receive all the events. Further changes can be made to check for changes to the width:
set vars(last.width) 0
proc doresize { win } {
variable vars
if { $win eq "." } {
set newwidth [winfo width $win]
if { $newwidth != $vars(last.width) } {
puts "Win $win now has width: [winfo width $win]"
if { $vars(last.width) != 0 } {
# this is not the first time, as last.width is not zero
# do something due to window resize.
}
set vars(last.width) $newwidth
}
}
}
References: grid, pack, bind

JavaFX synchronize Scroll pane content changes and its Vvalue

I have a Scrollpane containing 5 Titledpanes(Categories) each containing 2 images. Height of each TitledPane is 200 in expanded state and 25 in collapsed state.
Here is the image :
I have a text field in which I can enter the number of the Image to be selected.
For example, If I enter "4", the scroll pane scrolls to the Image-4 in Category-2 as shown below.
I am able to achieve this by calculating the Vvalue of the scroll pane based on the height to be scrolled and total height of the content inside the scrollpane.
Here is the issue
In the above example, if Category-2 is collapsed, I have to "Expand" it and then move to Image-4.
I am doing this by using the following code algorithm :
// Let the height of the scroll pane content with TitledPane-2 in collapsed state be (ht_ScrollPaneBefore = 825) and ScrollPane view port height be (ht_Viewport = 180). Let the ht of the scrollpane after expansion of TitledPane-2 be ht_ScrollPaneAfter which is calculated in step 3 in the following algorithm.
{
....
1. Expand TitledPane-2
2. Call applyCss() and layout() on the TitledPane to make the Expansion effective.(As addressed in the other query : https://stackoverflow.com/questions/26152642/get-the-height-of-a-node-in-javafx-generate-a-layout-pass)
3. Get the height of the total Content(ht_TotalContent) of the scroll pane with the expanded TitledPane-2.(ht_ScrollPaneAfter = 1000)
4. ****** Calculate the Vvalue based on (ht_TotalContent).(let it be Vvalue = 0.56) *****
5. Set the Vvalue to the scrollpane.
....
}
Issue
Since the expansion of the Titledpane is not yet applied "Visually" on the view, the Vvalue(0.52) is getting applied relative to ht_ScrollpaneBefore(800) which is leading to an incorrect scrolling ht as shown in the "Actual output" below.
Actual Output:
Expected:
Note: The ht of the scrollpane after the expansion of the TitledPane-2 is obtained successfully using the procedure described in the link: Get the height of a node in JavaFX (generate a layout pass). The Vvalue has been calculated based on ht_ScrollPaneAfter only not on ht_ScrollPaneBefore. The only problem here is the application of Vvalue is going wrong as the scroll pane view is not yet updated with the expanded TitledPane-2.
Code Sample :
private void scrollToImage() {
int imageNum = Integer.parseInt(textField.getText()); // Number entered in text field
int categoryNum = imageNum / 2 + imageNum % 2; // Which category the image number belongs to.
Bounds scrollViewBounds = mscr.localToScene(mscr.getBoundsInLocal()); // viewport bounds.
Platform.runLater(() -> {
System.out.println("Before: " + mvbx.getHeight());
titledPaneList[categoryNum - 1].setExpanded(true);
mvbx.applyCss();
mvbx.layout();
});
double scrollHt[] = {0.0};
//ht of the categories before selected image category.
for (int idx = 0; idx < (categoryNum - 1); idx++) {
scrollHt[0] += titledPaneList[idx].getHeight();
}
// check if the image is first/second image in the category.
int imageIdxInCategory = (imageNum % 2 == 0) ? 1 : 0;
// If the selected image is second image in the category,
// add the titlebar and first image ht to the scroll ht.
if (imageIdxInCategory > 0) {
scrollHt[0] += 25 //Title bar ht.
+ titledPaneList[categoryNum - 1].getInsets().getTop() // titled pane top insets
+ ((VBox) titledPaneList[categoryNum - 1].getContent()).getChildren().get(0).getBoundsInLocal().getHeight(); // ht of the first image
// Note: Since, my titledpane contains a vbox which contains the
// image number label and imageview,
// I am calculating the ht of the first vbox her in the above code.
}
Platform.runLater(() -> {
System.out.println("After: " + mvbx.getHeight());
double d_ScrollHtPerPix = 1
/ (mvbx.getHeight()
- (scrollViewBounds.getHeight() - mscr.getInsets().getTop() - mscr.getInsets().getBottom()));
mscr.setVvalue(scrollHt[0] * d_ScrollHtPerPix);
});
}
}
Output :
When the category of the selected image is collapsed,
Before : 825
After : 825
As u see, the height of the scrollpane content is same even after expanding the collapsed category.

How do I set the variables for setSelect to get a full preview of an image with jCrop?

I want to have full preview for image, but it's giving me 70% of the image.
What should I do with the x2 and y2 variables for setSelect?.
jQuery('#preview').Jcrop({
minSize: [32, 32], // min crop size
aspectRatio: 1, // keep aspect ratio 1:1
bgFade: true, // use fade effect
bgOpacity: .3, // fade opacity
//setSelect: [0, 0, 768, 540],
//setSelect : [0,Math.round($('#preview').height()),Math.round($('#preview').width()/200),Math.round($('#preview').height()/200)],
setSelect : [0,0,Math.round($('#preview').width()),Math.round($('#preview').height())],
onChange: updateInfo,
onSelect: updateInfo,
onRelease: clearInfo
}
You should check the div.jcrop-holder with object inspector of your browser. Definitely its width is not 100%. It can caused by your CSS code so you should find the problem there.
If you see that the div.jcrop-holder has style property and the width is set you need to set boxWidth option. For further information see the relevant page of the documentation: http://deepliquid.com/content/Jcrop_Sizing_Issues.html

iOS 8 Bug with UIImagePickerController Image Crop

I am having an issue with UIImagePickerController with allowsEditing = YES.
I am unable to crop the image from the bottom but also I have an extra empty space on top when moving the crop rectangle.
Also in the method.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
I log info and it gives me wrong CropRect (which is not square!)
UIImagePickerControllerCropRect = "NSRect: {{0, 357}, {666, 646}}";
UIImagePickerControllerEditedImage = "<UIImage: 0x7f9b8aa47b30> size {640, 618} orientation 0 scale 1.000000";
UIImagePickerControllerMediaType = "public.image";
UIImagePickerControllerOriginalImage = "<UIImage: 0x7f9b8868e5a0> size {1500, 1001} orientation 0 scale 1.000000";
Does anyone has this bug and how do you fix it?
See the picture below
I have no idea how, but i totally removed "View controller-based status bar appearance" key row (just fully delete this row) in .plist file and it fixed this bug
I couldn't set the "View controller-based status bar appearance" to YES, so I have tried to hide the status bar when I show the UIImagePickerController like so:
let imagePickerController = UIImagePickerController()
...
myViewController.present(imagePickerController, animated: true) {
UIView.animate(withDuration: 0.25, animations: {
UIApplication.shared.isStatusBarHidden = true
})
}
Then on the UIImagePickerControllerDelegate didFinishPickingMediaWithInfo I show the status bar, and it worked.

Resources