basic.aspx
来自「经典编程900例(C语言),主要是C基础知识」· ASPX 代码 · 共 164 行
ASPX
164 行
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Basic Resizing Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="basic.css" />
<link rel="stylesheet" type="text/css" href="../examples.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js" ></script>
<script type="text/javascript" src="../../ext-all-debug.js" ></script>
</head>
<body>
<form id="form1" runat="server"></form>
<ssfx:Scriptlet runat="server" ID="scriptlet" EnableDebugging="True" PrecompiledScriptlet="SampleScripts.resizable.BasicScript">
<References>
<ssfx:AssemblyReference Name="sscorlib"></ssfx:AssemblyReference>
<ssfx:AssemblyReference Name="ssfx.Core"></ssfx:AssemblyReference>
<ssfx:AssemblyReference Name="ExtSharp"></ssfx:AssemblyReference>
<ssfx:AssemblyReference Name="SampleScripts"></ssfx:AssemblyReference>
</References>
</ssfx:Scriptlet>
<h1>Resizable Examples</h1>
<p>These examples show how to apply a floating (default) and pinned Resizable component to a standard element.</p>
<p>Note that the js is not minified so it is readable. See <a href="basic.js">basic.js</a> for the full source code.</p>
<p>
<b>Basic Example</b><br />
This is a basic as you get. To resize the box, position your mouse anywhere near the bottom,
right or border right edge of the box. This example uses the default "floating" handles.
</p>
<div id="basic">Resize Me!</div>
<pre class="code"><code>new Resizable("basic", new ResizableConfig()
.width(200)
.height(100)
.minWidth(100)
.minHeight(50)
.ToDictionary());</code></pre>
<hr>
<p>
<b>Wrapped Elements</b><br />
Some elements such as images and textareas don't allow child elements. In the past, you had
to wrap these elements and set up a Resizable with resize child. Resizable will
wrap the element, calculate adjustments for borders/padding and offset the handles for you. All you have to
do is set "wrap:true". The manual way of specifying a "resizeChild" is still supported as well.
</p><p>
<b>Pinned Handles</b><br />
Notice this example has the resize handles "pinned". This is done by setting "pinned:true".
</p><p>
<b>Dynamic Sizing</b><br />
If you don't like the proxy resizing, you can also turn on dynamic sizing. Just set "dynamic:true".
</p>
<p>
Here's a textarea that is wrapped, has pinned handles and has dynamic sizing turned on.
</p>
<textarea id="dwrapped">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna. Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa.
Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit. Quisque dolor magna, ornare sed, elementum porta, luctus in, leo.
</textarea><br /><br />
And look how simple the code is, even my grandma could write it.
<pre class="code"><code>new Resizable("dwrapped", new ResizableConfig()
.wrap(true)
.pinned(true)
.width(450)
.height(150)
.minWidth(200)
.minHeight(50)
.dynamic(true)
.ToDictionary());</code></pre>
<hr>
<p>
<b>Preserve Ratio</b><br />
For some things like images, you will probably want to preserve the ratio of width to height. Just set preserveRatio:true.
</p>
<img id="wrapped" src="sara.jpg" width="200" height="250"/>
<pre class="code"><code>new Resizable("wrapped", new ResizableConfig()
.wrap(true)
.pinned(true)
.minWidth(50)
.minHeight(50)
.preserveRatio(true)
.ToDictionary());</code></pre>
<hr>
<p>
<b>Transparent Handles</b><br />
If you just want the element to be resizable without any fancy handles, set transparent to true.
</p>
<img id="transparent" src="zack.jpg" width="100" height="176"/>
<pre class="code"><code>new Resizable("transparent", new ResizableConfig()
.wrap(true)
.minWidth(50)
.minHeight(50)
.preserveRatio(true)
.transparent(true)
.ToDictionary());</code></pre>
<hr>
<p>
<b>Customizable Handles</b><br />
Resizable elements are resizable 8 ways. 8 way resizing for a static positioned element will cause the element to be positioned relative and taken out of the document flow. For resizing which adjusts the
x and y of the element, the element should be positioned absolute. You can also control which handles are displayed by setting the "handles" attribute.
The handles are styled using CSS so they can be customized to look however you would like them to.
</p>
<p>
This image has 8 way resizing, custom handles, is draggable and 8 way preserved ratio (that wasn't easy!).<br />
<b>Double click anywhere on the image to hide it when you are done.</b>
</p>
<img id="custom" src="sara_and_zack.jpg" width="200" height="152" style="position:absolute;left:0;top:0;"/>
<div style="padding:8px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;"><button id="showMe">Show Me</button></div>
<pre class="code"><code>Resizable custom = new Resizable("custom", new ResizableConfig()
.wrap(true)
.pinned(true)
.minWidth(50)
.minHeight(50)
.preserveRatio(true)
.handles("all")
.draggable(true)
.dynamic(true)
.ToDictionary());</code></pre>
<hr>
<p>
<b>Snapping</b><br />
Resizable also supports basic snapping in increments.
</p>
<div id="snap"></div>
<pre class="code"><code>new Resizable("snap", new ResizableConfig()
.wrap(true)
.width(250)
.height(100)
.handles("e")
.widthIncrement(50)
.minWidth(500)
.dynamic(true)
.ToDictionary());</code></pre>
Warning: Snapping and preserveRatio conflict and can not be used together.
<hr>
<p>
<b>Animated Transitions</b><br />
Resize operations can also be animated. Animations support configurable easing and duration.
Here's a very basic clone of the first element, but with animation turned on. I used a "backIn"
easing and made it a little slower than default.
</p>
<div id="animated">Animate Me!</div>
<pre class="code"><code>new Resizable("animated", new ResizableConfig()
.width(200)
.pinned(true)
.height(100)
.minWidth(100)
.minHeight(50)
.animate(true)
.easing("backIn")
.custom("duration", .6)
.ToDictionary());</code></pre>
Warning: for obvious reasons animate and dynamic resizing can not be used together.
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?